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.

In Firefox, how can I prevent pages from overriding Firefox built-in keyboard shortcuts through Javascript on a per-key basis? Preferably on a per-site basis, too? The most frustrating override is the forward slash ('/') that's linked to "Find in page". Sites like Google search results, Twitter timelines, some wikis, and other pages steal the slash key for their own search boxes, which is completely wrong.

Since my rep lets me ask, edit, and answer questions, but not add comments, this is basically a duplicate of these other two questions that weren't properly answered:

How do a stop a website for overriding my keyboard short cuts

Firefox: don't allow websites to override the / (slash) key

share|improve this question
I get frustrated with PHPMyAdmin overriding ctrl-<left arrow>... it's a good question –  Highly Irregular May 2 '12 at 21:42
I can't stand websites that override default behaviour. A lot do it with middle-clicks as well. See this related question for a solution to that problem. –  Cam Jackson Oct 18 '12 at 1:23
Simple fucking answer: You CANT! hear me? CANT. simple 4 letter answer. –  TechLife Jan 5 at 20:10

2 Answers 2

Building on edymtt's answer, I've created a userscript which disables only specific keyboard shortcuts. You can add more shortcuts to disable by adding keycodes to the keycodes array, or restrict which sites to apply it to by replacing the @include tag with one or more patterns.

Install using greasemonkey.

// ==UserScript==
// @name           Disable keyboard shortcuts
// @description    Stop websites from highjacking keyboard shortcuts
// @run-at         document-start
// @include        *
// @grant          none
// ==/UserScript==

keycodes = [191] // Keycode for '/', add more keycodes to disable other key captures

document.addEventListener('keydown', function(e) {
//    alert(e.keyCode); //uncomment to find out the keycode for any given key
    if (keycodes.indexOf(e.keyCode) != -1)
        e.cancelBubble = true;
    return false;
share|improve this answer
Awesome! Almost complete solution for meta keys, too--- I was trying to keep Google Docs from intercepting Previous-tab (Cmd+Left) and Next-tab (Cmd+Right) and found that I also needed to set useCapture to true; i.e., document.addEventListener('keydown', yourHandlerFn, true) –  chbrown Oct 6 '14 at 2:28

With regard to Google and the Quick Find shortcut, you can install this Greasemonkey script:


As the description says, it "stops google from focusing the search input on every key press" -- in particular, if you press / with the keyboard focus outside the search box the Quick Find will appear, as it will on other web sites.

I have only installed it without touching the code, but I think it could be easily adapted to work with other sites and/or other shortcuts.

share|improve this answer
To clarify: this userscript stops ALL keyboard shortcuts on pages which it is enabled for, preserving the browser's own functionality. To apply it to other websites just add more @include tags. –  MikeFHay May 15 '13 at 12:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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