Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Many websites, especially everything involving rich text editing (this site is guilty as well), steal keyboard shortcuts normally used to control Firefox and make them do something else instead. It is totally infuriating when I press something like Cmd-number, Cmd-L, Cmd-T, or Cmd-K and it doesn't do what I want it to. Can I make it stop?

Actually, it would probably be for the best if I could forbid stealing of all Cmd-* shortcuts. I've never seen them used for anything useful. Is it possible?

share|improve this question
Agreed, it's infuriating. FogBugz has a very good implementation of keyboard shortcuts. CTRL-; enters shortcut mode and highlights all the commands visible on the screen with the available shortcuts. Every shortcut is a combo, so new case is CTRL-; N and edit is CTRL-; E. Very easy to get used to and zero conflicts. I wish more sites would use something like this 'cause it's easier for the user and doesn't override browser shortcuts. Too bad SuperUser doesn't do this since it's from same people as FogBugz. – Sam Jul 30 '10 at 19:57
See also… – Mechanical snail Oct 4 '13 at 5:47
This is being discussed at this feature request on Bugzilla. – Mechanical snail Oct 4 '13 at 5:49
I visit lots of intranet pages at work that somehow mess up cmd+N, so I can never open new browser windows from the keyboard! So annoying! – NicolasMiari May 12 at 5:14

Thanks to Greasemonkey's new "@run-at" property, this is now possible!

I took inspiration from this script and this script to combine them into a Userscript that sucessfully intercepts the keyboard shortcuts Ctrl+t and Ctrl+s. I tested in in Firefox 17 ESR and Firefox 25.

// ==UserScript==
// @name           Disable Ctrl+s and Ctrl+t interceptions
// @description    Stop websites from highjacking keyboard shortcuts
// @run-at         document-start
// @include        *
// @grant          none
// ==/UserScript==

// Keycode for 's' and 't'. Add more to disable other ctrl+X interceptions
keycodes = [83, 84];  

(window.opera ? document.body : document).addEventListener('keydown', function(e) {
    // alert(e.keyCode ); //uncomment to find more keyCodes
    if (keycodes.indexOf(e.keyCode) != -1 && e.ctrlKey) {
        e.cancelBubble = true;
    // alert("Gotcha!"); //ucomment to check if it's seeing the combo
    return false;
}, !window.opera);
share|improve this answer
This was very helpful. OS X users should swap out e.ctrlKey for e.cmdKey and e.cmdKey && e.shiftKey to reclaim most of their browser shortcuts. – JamesGecko Apr 9 '14 at 17:04
This script works for me to fix CTRL+TAB by adding 9 to the keycodes array. Thanks! – Mike Mueller Aug 12 '14 at 23:09
@JamesGecko Found out via this answer you should/could use the e.metaKey for the command key. – riezebosch Apr 1 '15 at 9:08
This code works! Keep in mind that it filters not only Ctrl+Key, but also Ctrl+Alt+Key, Ctrl+Shift+Key and Ctrl+Alt+Shift+Key, because it only checks for the state of the Ctrl modifier. – romkyns Oct 26 '15 at 23:28
First question: for a script reputed to work on Firefox, why does it check whether the browser is Opera? And second question: the comment says character codes for 's' and 't', but the codes are really for 'S' and 'T'. Do I need to specify the uppercase code for some reason? Thanks. – Douglas Held Dec 15 '15 at 9:23

Since the issues seems to be JavaScript keyboard events stealing keypresses, would it not be possible to build a JavaScript script (to be used via Greasemonkey) that unbinds these all keyboard events, thus returning the proper usage of each shortcut to the browser?

I'm not sure how feasible this is, but someone with more JavaScript / Greasemonkey experiance may be able to help (might be worth asking on SO).

share|improve this answer
This works through onKeyPress mechanism - Firefox sends every keypress to website first, and only looks at it afterwards if it was not canceled or intercepted. Some Greasemonkey magic that would intercept keypresses before website and somehow run firefox functions directly might be possible, but it's far from obvious. – taw Aug 5 '10 at 16:54

The problem is that any page can run Javascript that sets up an event handler to grab keypress events, and Firefox's javascript controls aren't sufficiently fine-grained to stop it without breaking other javascript features.

The only way to prevent this is to disable Javascript (Tools -> Options, [Content] tab, uncheck the Enable JavaScript). Or you can disable Javascript on a per-site basis with an extension like NoScript.

Firefox lets you prevent certain uses of Javascript, like moving/resizing windows, changing or disabling the context menu, etc; but there's nothing to prevent web-sites intercepting keyboard events.

Maybe there's an extension which gives this level of control - I'm not aware of one.
There's Javascript Options, but that extension is no longer being updated.

share|improve this answer
Javascript Options and a few other extensions I tried don't support this. Blocking all javascript would make the web pretty much unusable, this isn't really an option. – taw Jul 31 '10 at 2:09
up vote 3 down vote accepted

Extensive research shows that as of current version of Firefox (3.6.x) this is impossible - all key binding conflicts are resolved with priorities: System > Website > Firefox - a rather stupid order that is. None of addons I've tried seems to be able to fix it.

Possibly it might become doable in future versions, but right now the answer is - Impossible.

share|improve this answer
Using FF 30.0 almost 4 years later and this is still an issue. I'll try Martin's Greasemonkey idea. – LGT Jul 28 '14 at 20:59

It is likely that third party plugins are taking the focus from the main browser window. In that case the keyboard input (except interrupts) will get intercepted by the plugin. If you don't like this you can always remove the offending plugin(s) [I would assume it is likely flash].

share|improve this answer
Flash does it too, but plain Javascript can steal shortcuts. Start a new question here, and press Cmd-L (Ctrl-L on non-Macs) while in the question text window. Instead of going to url bar as it should, shortcut will be stolen and you'll see some insert hyperlink dialog. It used to be rare, but too many websites started doing it recently. – taw Jul 27 '10 at 1:22
I just tried it on Windows 7 running Firefox and I jumped directly to the address bar like it normally does. – Daisetsu Jul 28 '10 at 5:39
Sorry, I wasn't clear - this only happens when rich textbox dialog is selected. Did you do that? I tested in on OSX with Firefox, Opera, Safari, and Chrome. In all four normally Cmd-L jumps to url bar (and Ctrl-L does nothing). When editing question body both Cmd-L and Ctrl-L show insert hyperlink dialog instead. – taw Jul 28 '10 at 22:07
Looks like you are right. I have no idea how to prevent this. :( It's an interesting question now so I'm upvoting your question. If nobody answers it I'll throw a bounty on it. – Daisetsu Jul 29 '10 at 0:01
The problem is not with plugins. Plugins are a separate problem by themselves. And a different problem, after all. In plugins, all the focus is stolen by the plugin, because it's a separate entity. With JavaScript, the firefox UI is JavaScript and has its own bindings, but sites can define bindings that are at the same level. So far, there is still no mechanism to prevent this. – njsg Jan 18 '13 at 17:19

After much testings on various browsers, it is easier to intercept the keys when they are down (not pressed) because some of this "App integrated keys" are difficult to intercept with the "keypress" event.

I came up with this script that is sort of cross browser compatible (I didn't test for Microsoft's IE). Notice that the browsers return different codes for some keys. In my case I wanted to prevent Ctrl+P.

The key "P" on chrome is seen as e.keyCode == 80, on opera, it is e.charCode == 16, while on firefox it is e.charCode == 112

$(document).on('keydown', function(e) {
    if(e.ctrlKey && (e.key == "p" || e.charCode == 16 || e.charCode == 112 || e.keyCode == 80) ){
        alert("Please use the Print PDF button below for a better rendering on the document");
        e.cancelBubble = true;


I used jQuery.

share|improve this answer

Perhaps you can use Autohotkey or Autoit, one of those programs and if you can do hotkey combos and link them to the firefox functions, say

Ctrl-; T to new tab

Ctrl-; N to new window, and so on.

I don't know how to use Autohotkey or Autoit, so someone else will have to verify that this could work, I only offer this as a potential idea.

share|improve this answer

Firefox current version enables us to "disable javascript to hijack context menu":

Tools/Options/Content/Enable Javascript Advanced/Disable or replace context menus

But there is no feature to "disable javascript to hijack keyboard shortcuts".

ps. I hate twitter website, its keyboard shortcuts conflict with my system-based keyboard shortcuts: J, K, L, I

I've made feature request on, please comment there:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .