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?
10 Answers
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:
- Go to System -> Preferences -> Keyboard settings
- Click Add
- Give it a name like fake setting and enter
/bin/falseas command. Apply your changes. - 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.
-
2Awesome answer, and how did you do the styled button shortcuts! :) – jathanism Aug 11 '10 at 13:37
-
3@jathanism: Use the `kbd` html tag. – Lars Haugseth Aug 11 '10 at 15:33
-
4When you want to press `Ctrl-Q` the window will close. You can never assign this key using this method – Anwar Oct 15 '12 at 06:23
-
3@AnwarShah -- I just tried this solution and it worked for me. – Sam King Apr 20 '14 at 05:22
-
I'm using GNOME Shell 3.20.2 on Archlinux and this worked for me. – aaaaaa May 21 '16 at 13:38
-
this is so hacky but it works splendidly. Ubuntu GNOME 16.04. – Jay Jan 06 '17 at 16:01
-
Fail. This doesn't let me use Ctrl+Q in an application that defines this shortcut by default (e.g. IntelliJ) – Mark Jeronimus Jan 18 '17 at 15:35
-
@MarkJeronimus: guess that's a problem of the application, then. But I'm sure you can disable that in IntelliJ as well. – netchkin Mar 01 '17 at 06:02
-
I want it in IntelliJ because it's a standard shortcut across platforms – Mark Jeronimus Mar 01 '17 at 11:49
-
1keyconfig no longer works in Firefox 57. – Damian Yerrick Sep 26 '17 at 15:12
-
System-wide disable of `Ctrl+Q` is all that worked for me. I use the command `true`. – Paul Mar 05 '20 at 17:57
-
1this works in ubuntu mate 20.04, but the program is named like "keyboard shortcuts" – qdinar Sep 28 '20 at 08:02
-
I love this solution, but I modified it to use Ctrl+Q as "Hide Window" instead – rubo77 Mar 16 '21 at 22:10
Probably inserting the shortcut under System -> Preferences -> Keyboard Shortcuts and "disabling" it should do the trick.
- 164
- 3
-
7Instead of just typing away do a bit of research if your not 100% certain. It would have costed you 2 secs to find that it is not there. – LassePoulsen Aug 11 '10 at 07:33
-
1Well, it is if you add it, isn't it? Maybe I didn't express myself correctly. But apparently, there *is* an easy fix since it's worked for me. – mariachris Aug 11 '10 at 09:04
-
Maybe not, it is still not a very nice way to do it... This way you will never be able to use Ctrl+W for any thing! For instance in bash Ctrl+W means delete word backwards. – LassePoulsen Aug 11 '10 at 11:13
-
It does work and it is exactly what has been asked for. @LassePoulsen why should CTRL+W be affected from this? – Murmel Dec 01 '16 at 15:54
You can go to System → Preferences → Keyboard 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.
- 12,964
- 10
- 49
- 77
- 34,993
- 11
- 88
- 110
-
Kind of a nice and easy fix, but I rather recommend to use a browser's extension. Using system preferences to override Ctrl+Q system-wide would result in some applications being unable to use that shortcut - e.g. you won't be able to use Ctrl+Q in IntelliJ IDEA to show documentation pop-up. – falconepl Jun 27 '15 at 14:48
-
2Well, the question is about disabling this combo system-wide not app per app ;). – Javier Rivera Jun 29 '15 at 06:30
-
For newer Firefox versions, you can disable it as follows:
- Go to
about:config. - Set
browser.quitShortcut.disabledtotrue. - 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.
- 12,964
- 10
- 49
- 77
- 4,354
- 6
- 25
- 31
If Ctrl + Q closes the keyboard settings window, like it did for me, youi can do the following:
- Set the shortcut to another value.
- Close the window and wait until the updated shortcut appears somewhere in
~/.gconf/desktop/gnome/keybindings/*. - Open that file and edit the
stringvalueof that command to read<Primary>q. - Reboot the PC.
This worked for me as opposed to the accepted answer.
- 12,964
- 10
- 49
- 77
- 1,576
- 5
- 18
- 39
-
Even that did not work for me. I tried the below:
– vishvAs vAsuki May 28 '13 at 21:26/bin/false dummy2 <Primary>q -
1
My current workaround is to create a new shortcut in System Settings → Keyboard → Shortcuts. 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.
- 12,964
- 10
- 49
- 77
- 3,860
- 4
- 29
- 34
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.
- 12,964
- 10
- 49
- 77
- 151
- 2
-
It seems that these settings although preserved after restart does not provide expected behavior (Ubuntu 14.04). Also, after being applied, using Ctrl+Q shortcut with focused Nautilus window makes it hang/unresponsive. – falconepl Jun 27 '15 at 14:21
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.
- 12,964
- 10
- 49
- 77
- 643
- 9
- 13
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.
- 12,964
- 10
- 49
- 77
- 263
- 4
- 10
My way is going to System → Preferences → Keyboard 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.
- 12,964
- 10
- 49
- 77
- 111
- 4
-
This is not an appropriate solution because the command "a" will run every time Ctrl+Q is pressed. And it will override shortcuts of other applications too. – Parag Katoch May 30 '21 at 02:03
