搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

Learn More

Key binds

  • 5 个回答
  • 1 人有此问题
  • 280 次查看
  • 最后回复者为 cor-el

more options

Hi

I am using mozilla firefox on windows 10.

I sometimes fat finger ctrl+shift+w or ctrl+shift+q which closes the browser instead of just closing the tab which I indented.

Is there a way to disable these 2 key binds?

Best regards child

Hi I am using mozilla firefox on windows 10. I sometimes fat finger ctrl+shift+w or ctrl+shift+q which closes the browser instead of just closing the tab which I indented. Is there a way to disable these 2 key binds? Best regards child

所有回复 (5)

more options

ctrl+w (close tab) and ctrl+shift+w (close firefox) are very close to each other.

I was thinking it would be enough to have ctrl+shift+q to close firefox (not also ctrl+shift+w).

Using a mouse to close a tab is of course possible. But key binds are very nice to use, both for speed and comfort. Imagine not having a keyboard at all and instead use an on screen keyboard and click every single key with the mouse. It may solve something but it's not really a suitable solution.


Disable a this keybind would be really nice for my problem. Do anyone know how to? Using a mouse instead of any shortcuts is not good enough for me.

more options

There are extensions for configuring keyboard shortcuts but AFAIK they don't enable you to disable Firefox shortcuts. The only way I know is to assign those shortcuts to other actions on your system. I have trained myself to use shortcuts which I set myself using the extension linked below.

https://addons.mozilla.org/en-GB/firefox/addon/select-after-closing-current/

more options

If you close a window accidentally then you can restore that window via "History -> Recently Closed Windows".

Firefox 87+ versions have a pref to disable Ctrl+Shift+Q (Mac/Linux:Command/Ctrl+Q) to close Firefox. You need to close and restart Firefox after toggling this pref.

  • about:config => browser.quitShortcut.disabled = true

Disabling the "Ctrl+Q" warning is controlled by this pref.

  • about:config => browser.warnOnQuitShortcut

由cor-el于修改

more options

cor-el said

If you close a window accidentally then you can restore that window via "History -> Recently Closed Windows". Firefox 87+ versions have a pref to disable Ctrl+Shift+Q (Mac/Linux:Command/Ctrl+Q) to close Firefox. You need to close and restart Firefox after toggling this pref.
  • about:config => browser.quitShortcut.disabled = true
Disabling the "Ctrl+Q" warning is controlled by this pref.
  • about:config => browser.warnOnQuitShortcut

Thank you! This disabled the "Ctrl+Shift+Q" command.

Is there a way to disable "Ctrl+shift+W" as well?

由hwoarangwins2于修改

more options

The only way to disable the Ctrl+Shift+W shortcut to close a window is via an autoconfig,cfg file like I posted in the thread.

See also:

In your case you need to modify this line:

  • let KEYS = ['key_quitApplication','key_reload'];

Change to:

  • let KEYS = ['key_closeWindow'];

In case you want to include more keys, see also:


You can use the autoconfig.cfg file in the Firefox installation folder to initialize (set/lock) preferences and run privileged JavaScript code.

To use Autoconfig, place two files into the Firefox installation directory.

  • on Windows, they go into the same directory where Firefox is installed
  • on macOS, they go into the Contents/Resources directory of the Firefox.app

The autoconfig.js file that specifies to use autoconfig.cfg is placed into the "defaults\pref" directory where the channel-prefs.js file is located.

//
pref("general.config.filename", "autoconfig.cfg");
pref("general.config.obscure_value", 0);
pref("general.config.sandbox_enabled", false); // disable sandbox to allow privileged JavaScript

The autoconfig.cfg file is placed at the top level of the Firefox directory.

  • autoconfig.cfg and autoconfig.js need to start with a comment line (//)
  • autoconfig.js needs to use Unix line endings (LF instead of CR/LF)

See also:


Content of autoconfig.cfg

// first line in autoconfig.cfg is a comment line
try {
 let {classes:Cc, interfaces:Ci, manager:Cm, utils:Cu} = Components;
 let Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
 function ConfigJS() { Services.obs.addObserver(this, 'chrome-document-global-created', false); }
 ConfigJS.prototype = {
  observe: function (aSubject) { aSubject.addEventListener('DOMContentLoaded', this, {once: true}); },
  handleEvent: function (aEvent) {
   let document = aEvent.originalTarget;
   let window = document.defaultView;
   let location = window.location;
   if (/^(chrome:(?!\/\/(global\/content\/commonDialog|browser\/content\/webext-panels)\.x?html)|about:(?!blank))/i.test(location.href)) {
    if (window._gBrowser) {
     let attr, elm, key, mbo;
      let KEYS = ['key_closeWindow'];
      let ATTR = ['key','modifiers','command','oncommand'];
      for (key in KEYS){
       elm = window.document.getElementById(KEYS[key]);
       if (elm) for (attr in ATTR) if (ATTR[attr] in elm.attributes) elm.removeAttribute(ATTR[attr]);
      }
    }
   }
  }
 };
 if (!Services.appinfo.inSafeMode) { new ConfigJS(); }
} catch(e) {Cu.reportError(e);}

由cor-el于修改