Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This question already has an answer here:

Some web sites (an increasing number of them these days, it seems) hijack various key combinations to perform actions within and defined by the web site itself. There's the specific example of / in GMail in an inappropriately titled question; there's the StackExchange edit box which hijacks Ctrl+G for "Add image" (rather than Firefox's normal "Find next"); there's Facebook hijacking Esc to hide an overlay rather than the usual "stop loading". I'm sure I could go on and on with examples, but this should be enough to illustrate that this question is not about any one specific website.

I use the keyboard extensively and keyboard shortcuts behaving differently based on which web site I am on is a major annoyance to me. If I press a browser-defined keyboard shortcut, I want the action defined by the browser to be taken, not something else. I also don't want certain features which are normally accessible by keyboard to not be accessible by keyboard, or suddenly be remapped to other key combinations.

I realize that this may make some things more cumbersome on some sites, but in this case I prefer consistency.

Is it possible to set up Firefox to prevent or ignore such hijackings by web sites and favor Firefox's own defined behavior?

A solution that works at least for Firefox versions 20, 21 and 22 on both Linux and Windows would be ideal.

Edit Mozilla Bugzilla Bug 380637 Should web pages be able to override the browser's keyboard shortcuts? seems to indicate it is at least being looked at. That bug was initially submitted in mid-2007 and is still active as of mid-2013. Interestingly enough, bug 775002 Enable users to disable javascript to hijack keyboard shortcuts was considered a duplicate around Firefox 15.

share|improve this question

marked as duplicate by Darth Android, Tog, gronostaj, Excellll, mpy Jul 22 '13 at 20:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

I suspect they're doing this via Javascript. If so there would be no generic way to disable it without disabling Javascript. –  Daniel R Hicks Jul 4 '13 at 11:42
yep maybe api.jquery.com/keypress . It would be interesting if there was an addon that allowed selective .js re-writing at the client side. you could then just comment out these calls using regex or similar –  James Jul 4 '13 at 11:59
Even if done through Javascript,somewhere there has to be a key press listener involved, and that functionality is provided by the browser. I see no reason why that code couldn't be modified such that the browser interprets any keystrokes (maybe with modifier keys) first, and if the browser takes any action in response, the key press is not passed on to the Javascript provided by the web page. Making such behavior configurable (if you don't want to expose it through the settings GUI, there's still about:config which already allows access to many such advanced settings) should be fairly easy. –  Michael Kjörling Jul 4 '13 at 12:18
@Downvoter Why the downvote? –  Michael Kjörling Jul 4 '13 at 17:22
@Karan That question is a full three years old and the accepted answer talks about Firefox 3.6. While I don't exactly agree with Firefox's current version numbering scheme, we're probably well above 20 releases since then, over three years of development. What's to say the answers in it are still valid to current versions of Firefox? –  Michael Kjörling Jul 4 '13 at 17:24

2 Answers 2

You could use Vimperator plugin. Aimed at making Firefox a keyboard-only interface, it first listens to any keystroke that you press and performs its own actions. Sometimes when you would require to use the site's defined keyboard hijacks, you could easily enable/disable a pass-through mode for sometime.

Let's take the case of GMail, which offres a host of keyboard shortcuts. But when you press any such shortcut, it is handled by Vimperator itself. For example, pressing / inside GMail usually places the cursor in the search box. But pressing / in a GMail page when Vimperator is active triggers its default page search (ala searching in Vim editor). Same case for other GMail shortcuts like o c or even Ctrl+Enter. What this means is that, Vimperator will be the 0th listener for keystrokes in Firefox, over-riding even the 1st possible listeners so that your keyboard shortcuts are global throughout the browser.

Vimperator is basically a Vim wrapper over Firefox. If you are comfortable with Vim, Vimperator will seem like a long-lost friend. :-)

Anyway, a few Vimperator keyboard shortcuts to get you started with:

o<link> opens the . This sequences causes the Vimperator command line (at the bottom of the screen) to be activated and the command open <link> will be placed there, with the space in the middle inserted for you. Press Enter to load the page.

t<link activates the command tabopen and opens the link in a new tab.

gt switches to next tab. Ctrl+Tab and Ctrl+PgUp/Dn also work.

gT switches to previous tabs.

ZZ closes FF after saving the session.

f labels all the links in the page view with highlighted numbers. Typing a number opens the link. All the highlighted fields are searchable. So, instead of typing numbers, you could type any of the text in the highlighted link that you want to go to.

F opens links in a background tab.

h j k l to navigate the page left down upand right

Vimperator offers a host of keyboard shortcuts (and certainly makes the whole experience painlessly mouse-free), and most of FF's default shortcuts function as they normally do. You can find shortcuts to highlight text, copy them, navigate the page as if it were a text document, zoom in/out, simulate the hover on a link, and simply put, anything that would make Firefox respond to a mouse.

The only place where it doesn't work as far as I've used it, is inside Flash boxes, because, FF can't reach what's inside them.

It might take a bit of getting used to if you don't know about Vim or are new to it. However, really extensive online help is just a :h<Enter> away.

Here is the link.

share|improve this answer
share|improve this answer
NoScript allows you to load or not load all of Javascript from particular domains. I use it already, and it's great at what it does, but have you tried using e.g. Facebook or StackExchange without Javascript? The experience is somewhere between pretty painful and downright unusable. Disabling all Javascript globally for Facebook just to get my Esc key back to normal is rather overkill. –  Michael Kjörling Jul 4 '13 at 12:30
try marking the script as untrusted Pic: i.stack.imgur.com/45aAv.png or use proxy to block any response from a script eg. fiddler –  Homer Simpsons Jul 4 '13 at 12:36
If I use NoScript to mark e.g. facebook.com as untrusted, no Javascript originating from facebook.com will execute. This is not what I want. Please re-read the question. –  Michael Kjörling Jul 4 '13 at 12:38
Got it use this Link: addons.mozilla.org/sv-se/firefox/addon/greasemonkey and script link: userscripts.org/scripts/show/125936 <= look here ("if (src.search(/bad\.js/) != -1) {") –  Homer Simpsons Jul 4 '13 at 12:49
I still don't see how that helps me. Can you edit it into your answer with a fuller explanation of how it answers the question? –  Michael Kjörling Jul 4 '13 at 13:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.