71

A lot of applications like Firefox, Chrome etc, get closed when I accidentally press Ctrl+Q instead of Ctrl+W because of the proximity of the Q and W keys on the keyboard. Is there a way this shortcut can be removed or reset on a system wide basis?

snoop
  • 4,110
  • 9
  • 41
  • 58

10 Answers10

102

The best way is to disable the keyboard setting in your specific application. For Firefox there is an extension keyconfig. This allows you to change keyboard settings.

If you want to disable Ctrl+Q for your whole system, I would suggest to make a new setting:

  1. Go to System -> Preferences -> Keyboard settings
  2. Click Add
  3. Give it a name like fake setting and enter /bin/false as command. Apply your changes.
  4. Click on 'Disabled' and press Ctrl+Q.

Now you should have a new entry with your applied name and your keyboard setting. Every time you press Ctrl+Q your system will run the command /bin/false which basically does nothing. So this is a workaround to disable the setting.

ardila
  • 107
qbi
  • 19,515
9

Probably inserting the shortcut under System -> Preferences -> Keyboard Shortcuts and "disabling" it should do the trick.

5

You can go to System → PreferencesKeyboard Shortcuts and assign this combo to an unused action. For example I assigned Ctrl+Q to switch to workspace 12 (no, I don't have 12 workspaces).

As a result this system wide setting overrides application one and Ctrl+Q no longer closes Firefox (likely the combo never reaches Firefox). It just does nothing.

Javier Rivera
  • 35,434
4

For newer Firefox versions, you can disable it as follows:

  1. Go to about:config.
  2. Set browser.quitShortcut.disabled to true.
  3. Restart the browser.

For other applications, the steps will differ. Chrome no longer closes on Ctrl+Q, so there is no need to change anything there. Note that in many other applications, Ctrl+Q is a useful shortcut, so disabling it system wide would break that functionality.

3

My current workaround is to create a new shortcut in System Settings → KeyboardShortcuts. If the shortcut is accidentally pressed, we receive an informative message.

  • Title: Quit Prevention
  • Command: notify-send 'Dear idiot' "Don't press ctrl-Q"
  • Shortcut: Ctrl+Q

This disables the command system-wide, however, which might be an acceptable tradeoff depending on your use case.

The above is Tested in Ubuntu 16.04.

Daniel C
  • 4,170
2

If Ctrl + Q closes the keyboard settings window, like it did for me, youi can do the following:

  1. Set the shortcut to another value.
  2. Close the window and wait until the updated shortcut appears somewhere in ~/.gconf/desktop/gnome/keybindings/*.
  3. Open that file and edit the stringvalue of that command to read <Primary>q.
  4. Reboot the PC.

This worked for me as opposed to the accepted answer.

Fluffy
  • 1,604
2

Here is a command-line version of the already-supplied GUI version. On some systems Ctrl+Q will close the accelerator input window without setting the shortcut, so this can be needed:

gconftool-2 --type string --set /desktop/gnome/keybindings/inhibit_ctrl_Q/name "Inhibit Ctrl+Q"
gconftool-2 --type string --set /desktop/gnome/keybindings/inhibit_ctrl_Q/action /bin/false
gconftool-2 --type string --set /desktop/gnome/keybindings/inhibit_ctrl_Q/binding "<Primary>q"

Note that this solution is for GNOME 2/Unity. A similar solution should be possible with gsettings for GNOME 3.

fuzzyBSc
  • 151
1

On Linux with Firefox Quantum, there is currently a bug that prevents extensions and explicit configuration from changing a built-in shortcut such as Ctrl+Q.

A workaround is to block it at the system level by e.g. installing the script from https://github.com/sasawat/firefox-ctrl-q-workaround and assigning it as the action of Ctrl+Q as a global shortcut.

JanKanis
  • 683
0

For me, disabling the Ctrl+Q shortcut system-wide is not the perfect solution, because it prevents applications other than Firefox, Chrome etc., to be notified when you use that shortcut. For example, IntelliJ IDEA uses Ctrl+Q as a default binding to show quick documentation pop-up.

If you are looking for a Firefox-only solution, I highly recommend Disable Ctrl-Q Shortcut plugin. In my opinion it's a better option than keyconfig mentioned by @qbi because its source is available on GitHub, while keyconfig is available only as a binary.

falconepl
  • 263
-1

My way is going to System → PreferencesKeyboard Shortcuts (yeah I know it's not there). Here you add one more shortcut with the Name "Do nothing", with a random Command with the Shortcut Ctrl+Q. Then the deadly combo should not bother you anymore anywhere.

screenshot