Can I merge these in jQuery? I’m using the HotKeys plugin.
$(document).bind('keydown', 'n', cycleNoise);
$(document).bind('keydown', 's', pickRandom);
$(document).bind('keydown', 'v', toggleTasks);
$(document).bind('keydown', 't', toggleTimer);
$(document).bind('keydown', 'up', hideTask);
$(document).bind('keydown', 'down', nextTask);
$('#duration').bind('keydown', 't', toggleTimer);
$('#duration').bind('keydown', 'n', cycleNoise);
$('#duration').bind('keydown', 's', pickRandom);
$('#duration').bind('keydown', 'v', toggleTasks);
$('#duration').bind('keydown', 'up', hideTask);
$('#duration').bind('keydown', 'down', nextTask);
In other words, is it possible to use document and '#duration' in the same selector. The following doesn’t seem to work:
$(document + ',#duration').bind(...);
EDIT:
I am using the jQuery HotKeys plugin. This prevents bubbling from text fields by design. Can I disable this feature just for this specific textbox by modifying the source? If so, please let me know how.
Also does the plugin merge the keydown events or is it really attaching 12 separate handlers? I don’t understand jQuery well enough to work it out. What’s the best solution to achieve the desired effect (acting on the hotkeys, except when in textboxes – apart from in '#duration' where the hotkeys should be bound).
Here you go:
where
inputis a reference to your INPUT element. In this case:Another solution is