Disabling Firefox keyboard shortcuts with JavaScript
First off, let me just say I feel really stupid for posting this. It seems like I stumbled onto something for the first time that should be common knowledge for a JavaScript developer. However, I am still making the post because I find this to be rather strange. Using the event ‘preventDefault’ method, you can completely disable Firefox’s built in keyboard shortcuts. If you click on the following js bookmarklet:
ruin my browser!
You won’t be able to pop firebug up with f12, ctrl+t yourself a new tab, get yourself a fresh version of the page with f5, and you won’t even be able to view the source. When I ran into this for the first time, I thought my computer was fucked up.
Apparently, this is also just Firefox. I just tested it in IE and Chrome, and it appears to do nothing. Is this a XUL thing?
Does anyone else find this to be strange or annoying? Is this surprising or am I stupid? It just seems like this shouldn’t happen.









September 28th, 2008 at 3:22 am
Shuts down my keys as well. I always thought this level of user annoyance was reserved for sites that use Flash.
May 25th, 2009 at 11:02 am
does not work anymore. too bad, that would have fixed my browser… i want those keyboard shortcuts disabled all of the time. they interfere with other shortcuts on my Mac, like the one for Megazoomer
May 25th, 2009 at 11:09 am
Still appears to work in linux and windows, i suspect that for whatever reason macs aren’t good enough to fail properly.
July 22nd, 2009 at 3:33 pm
Actually, this is good. Just used wrong.
I have developed a wysiwyg editor, and need to be able to respond to keyboard shortcuts. Once javascript must give me that level of control (and in all browsers) there is no reason to make it difficult to setup.
Mootools has all this built in: there is no difference between overiding the ctrl+b or overiding all keyboard shortcuts.
March 5th, 2010 at 1:11 pm
I clicked on the bookmarklet.It worked but how do I get the shortcuts back?
March 5th, 2010 at 4:08 pm
you could not have typed that comment if your keys were disabled. i suspect you are confused.