Is there any way to catch key combination ctrl+x+return in jquery(or javascript), such that if user presses this key combination, a function is called. I tried using the jquery hotkeys plugin, but that didn't worked.
jQuery bind() MethodUse the on() method instead. The bind() method attaches one or more event handlers for selected elements, and specifies a function to run when the event occurs.
bind() method is used for attaching an event handler directly to elements. Handlers are attached to the currently selected elements in the jQuery object, so those elements must exist at the point the call to . bind() occurs.
To check if an “enter” key is pressed inside a textbox, just bind the keypress() to the textbox. $('#textbox'). keypress(function(event){ var keycode = (event. keyCode ?
jQuery Hotkeys lets you watch for keyboard events anywhere in your code supporting almost any key combination. To bind Ctrl + c to a function ( f ), for example: $(document). bind('keydown', 'ctrl+c', f);
You may find using KeyboardJS to be a better solution. Its dam simple to use. Here are docs;
KeyboardJS.on('ctrl + x + enter', function() {
//do stuff on press
}, function() {
//do stuff on release
});
Also, if you want to force pressing ctrl before x or enter you can do this instead
KeyboardJS.on('ctrl > x + enter', function() {
//do stuff on press
}, function() {
//do stuff on release
});
http://robertwhurst.github.com/KeyboardJS/
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