Tech Tips

Firefox – Stop Pages from Hijacking the “Tab” Key

This one has been a personal pet-peeve of mine for a while now: text fields that hijack the “Tab” key, breaking the Ctrl-Tab & Ctrl-Shift-Tab keyboard shortcuts (to switch between browser tabs) in Mozilla Firefox. Many text editing components do this, particularly ones meant for editing code of some kind, so that pressing the tab key indents instead of switching to the next form field – inadvertently breaking a common, useful keyboard shortcut.

A Google search turns up numerous bug reports, feature requests, and support forum posts complaining about the issue – going as far back as Firefox 3.6 (2010), so it doesn’t seem to be a big priority for Firefox’s developers (evidently they’re too busy creating a poor imitation of Chrome’s user interface). But, as is often the case with Firefox issues, it is possible to fix with some 3rd-party add-ons – read on for the details.


So far, this solution posted on is the best fix I’ve found – it’s a “userscript” that allows you to prevent pages from hijacking specific keyboard shortcuts/keypresses, intended to be used with the Greasemonkey add-on. So first, you’ll need to download/install GreaseMonkey from the Firefox add-ons site. After you’ve installed the GreaseMonkey add-on (and restarted Firefox), you should see its icon – if you’re using the default them, it should appear to the right of the address bar (the “Tools” menu also contains a “GreaseMonkey” sub-menu with the same options).

The userscript posted on is setup to prevent pages from hijacking the “s” and “t” keys – a small modification was needed so that it would apply to the Tab key instead. Open the GreaseMonkey menu and click “New User Script,” then give it title like “Prevent tab key hijacking,” and enter something into the “namespace” field – doesn’t matter what, we’ll be replacing that in the next step. Click on the “OK” button and new window should appear, allowing you to enter the script – paste in the following text:

// ==UserScript==
// @name Disable Ctrl+tab 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 = [9];
(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);

Then click the “Save” button. And that’s it, the Ctrl-Tab shortcut will now work even if a pesky Tab key-hijacking text field has focus – it also seems to fix the recent issues with youTube hijacking keyboard shortcuts in Firefox. The only caveat is that it doesn’t help with plugins that hijack keyboard shortcut, E.g. Flash and Java


Linux and Windows web hosting plans start at just $7.95/mo.