I'm using the jQuery hotkeys plugin here: https://github.com/tzuryby/jquery.hotkeys
The plugin prevents hot keys from firing when you are inside an input field.
In my case, I want a hotkey to fire when inside an input box, not all but one in particular:
$(function() {
$(document).bind('keydown', 'Shift+return',function (evt) {
alert('got it')
});
});
Any ideas on how jQuery Hotkeys can be patched to allow for shift+return to be fired when inside an input/textarea field? but not fired for all the other hotkey bindings?
Thanks
According to the documentation, you can bind the event handler to any expression (not just document as in your example). You could explicitly bind the shift+return handler to whatever input elements you want by using a selector:
$("#test").bind("keydown", "shift+return", function(event) {
alert('got it');
});
Where test is the id of the input you want to listen to for the event.
I have it working here: http://jsfiddle.net/andrewwhitaker/vKrM9/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With