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.

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
3  
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 superuser.com/questions/399352/… –  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

7 Answers 7

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
3  
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

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
1  
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 at 20:59

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

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
2  
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

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 bugzilla.mozilla.org, please comment there: https://bugzilla.mozilla.org/show_bug.cgi?id=775002

share|improve this answer

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;
        e.stopImmediatePropagation();
    // alert("Gotcha!"); //ucomment to check if it's seeing the combo
    }
    return false;
}, !window.opera);
share|improve this answer
1  
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 at 17:04
    
This script works for me to fix CTRL+TAB by adding 9 to the keycodes array. Thanks! –  Mike Mueller Aug 12 at 23:09

Your Answer

 
discard

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.