I'm using to jQuery.hotkeys to bind keyboard events.
I'm trying to bind Ctrl+Shift+N
$(document).bind('keydown', 'ctrl+shift+n', function(e) {
e.preventDefault();
alert('Ctrl+Shift+N');
return false;
});
The above is not working. Any ideas?
Chrome doesn't let you take over some shortcuts.
If you use the following code http://jsfiddle.net/rNkmA/1/
$(document).bind('keydown', function(e) {
console.log(e.which);
console.log(e.ctrlKey);
console.log(e.shiftKey);
if (e.ctrlKey && e.shiftKey && e.which === 78) {
e.preventDefault();
console.log('Ctrl+Shift+N');
return false;
}
});
You'll see that the handler never gets called in Chrome
I suggest you use a shortcut that is not preassigned to chrome like alt+shift+n. That will work in FF, IE, Safari and Chrome (does anybody ever test for Opera?)
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