I'm making a javascript game and need to bind a lot of keys to different functions. This I know how to do, what I need some help on is over-riding the shortcut keys for the browser. in other-words I want to blur hot keys for the browser and divert them to my application.
+1
A:
I believe that if you stop the propogation of the event, then you will prevent the browser from catching the event.
an example of this:
element.onkeyup = function(e) {
var ev = e || event;
//do stuff here, probably with ev.keyCode
return false;
}
Jacob Relkin
2010-04-27 05:36:36
oh really? just like anything else. A bit of an oversight on my part, thanks very much.
Robert Hurst
2010-04-27 05:59:26
No need for the `ev.preventDefault();`, which in fact will cause an error in IE. If you're using this method of attaching an event handler then the `return false;` does the job in all browsers.
Tim Down
2010-04-27 09:01:51