views:

117

answers:

2

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
oh really? just like anything else. A bit of an oversight on my part, thanks very much.
Robert Hurst
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
A: 

doesnt work in chrome... or am i doing something wrong?

Funky
trying to override CTRL+S
Funky