I use jquery-hotkeys: http://github.com/jeresig/jquery.hotkeys
And this is my code:
$(document).bind('keydown', 'ctrl+s', function(){$('#save').click()});
but I cannot disable the browser's default behavior. How do I disable it?
I use jquery-hotkeys: http://github.com/jeresig/jquery.hotkeys
And this is my code:
$(document).bind('keydown', 'ctrl+s', function(){$('#save').click()});
but I cannot disable the browser's default behavior. How do I disable it?
It looks like you return false from your handler to disable "bubbling up" the event. So:
$(document).bind('keydown', 'ctrl+s', function(){$('#save').click(); return false;});
... but it may be browser specific. From your link:
Firefox is the most liberal one in the manner of letting you capture all short-cuts even those that are built-in in the browser such as Ctrl-t for new tab, or Ctrl-a for selecting all text. You can always bubble them up to the browser by returning true in your handler.
Others, (IE) either let you handle built-in short-cuts, but will add their functionality after your code has executed. Or (Opera/Safari) will not pass those events to the DOM at all.
So, if you bind Ctrl-Q or Alt-F4 and your Safari/Opera window is closed don't be surprised.