1

In Firefox, certain websites and certain plugins appear to "capture" the "control" key, so that when I try to open a new tab using Ctrl+T, nothing happens - or worse, something unexpected happens.

Examples:

  • On the Codecademy site, while editing code, Ctrl+T either does nothing, or switches the position of the two characters next to the cursor.
  • When viewing PDF's with the Adobe PDF plugin, Ctrl+Tdoes nothing.

Is there a way to disable this "feature"? I would like Ctrl+T to always "talk" to Firefox!

Edit:

I found that my question is very similar to the following questions:

The answers to these questions are interesting and relevant, but do not give a method on how to disable combinations such as Ctrl+T. Maybe a modified Greasemonkey script is the easiest solultion.

Edit 2 - A partial solution

The following Userscript (edit: now an answer) was mostly copy/pasted from StackExchange. To use it, you need to install GreaseMonkey. The script successfully captures Ctrl+T on some sites, for example Google (-> PopUp "Gotcha" appears), but not on the Codecademy site.

Also, I found another question pertaining to this subject: How to forbid keyboard shortcut stealing by websites in Firefox. It was raised in 2010, and the consensus was: It can't be done.

Edit 3 - Made the userscript work

I edited the userscript so that it now successfully prevents javascripts from intercepting Ctrl+T, and thanks to JC2k8 I also found a workaround for plugins (which I have not tested yet). I combined the information and submitted an answer - I'll wait a few days and accept the answer with the highest votes.

3
  • If you think that's annoying, then Ctrl+Tab in this situation probably makes you go bananas like it does for me lol. This also happens on video sites like DailyMotion.com if the video player is focused. Also, Google Chrome doesn't seem to suffer from this symptom as often
    – MonkeyZeus
    Nov 4, 2013 at 20:36
  • Ugh, madness. It's a design fail of Firefox, Websites, and OS's in general. It's 2013 and there is still no consensus as to what shortcuts should do what. Maybe you can try modifying the Greasemonkey script (the tab-keycode is 9). You might be in luck and it works on your favourite websites. Nov 4, 2013 at 21:15
  • not only Ctrl+T, Gerrit doesn't use any plug-ins but steals pretty much any Ctrl shortcuts which drives me nuts. Luckily my current company doens't use Gerrit
    – phuclv
    Dec 3, 2019 at 10:17

3 Answers 3

1

As soon as plugins (Flash, Acrobat Reader, Quicktime, …) are involved you're out of luck. Mozilla has always wanted to fix this bug by "fixing" the plugin API to allow plugins to send back "unused" keys but due to the scale of this work it has never been done. For a lengthy debate on this issue you can take a look at Bug 78414 at Bugzilla.

1
1

For plugins intercepting keystrokes: Thanks to JC2k8's answer, I came across this link where someone wrote a patch to intercept "important" keystrokes before they are send to plugin processes. It's pretty new and it is still in evaluation, but it's nice to see that someone is working on it. I have not tested it, but it might solve the problem.

For Javascript intercepting keystrokes: I finally managed to get my userscript working by combining this script and this script. I have to admit I'm not quite sure how the eventListener has to be attached and why it did not work earlier (see older versions of my question if you are interested). Anyway, the following script works at least on Firefox 17 ESR.

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

// Keycode for 't'. Add more to disable other ctrl+X interceptions
keycodes = [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);
1

You could capture the Ctrl+T key sequence at the OS level, and pass it through to firefox.

For example you could use AutoHotKey to listen for Ctrl+T and issue the command

"C:\Program Files\Mozilla Firefox\firefox.exe" -new-tab about:newtab

Replace about:newtab with an actual web page URL if you prefer. This opens a new tab in the existing instance of firefox. You should be able to trap the sequence only when ff has focus, but still capture it before javascript gets it.

You must log in to answer this question.

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