158

Is there any way to disable command+Q for quitting apps?

I tried adding this menuitem to the "Keyboard Shortcuts" preference pane (as suggested here), and remapping it to command+option+Q (slightly harder to hit), and the menu item changed to show this, but command+Q still causes the app to quit.

I'm using OS X 10.7, but I'd happily upgrade to 10.8 if it fixed this.

The app I really want this for is Firefox, but if there was a solution that disabled command+Q for every app, that would be fine, too.

9
  • 1
    Are you looking for a global hack or would you be able to just remap the applications you want to override? The latter is quite easy using the normal keyboard preference pane and making another shortcut (like command - shift - control - option - Q) that won't get pressed on a whim.
    – bmike
    Commented Jan 15, 2013 at 21:02
  • bmike: I'd take either, but as I said, I tried making it command-option-Q and it doesn't work. If I try entering command-option-shift-Q, it beeps and says the app System Prefs has cancelled logout.
    – Ken
    Commented Jan 15, 2013 at 23:45
  • The problem is you need to over ride quit on a per application basis and include the app name so that the full menu name is entered in the app-specific shortcut.
    – bmike
    Commented Jan 16, 2013 at 0:02
  • bmike: I was specifying the override for Firefox only, and including the app name in the menuitem override.
    – Ken
    Commented Jan 16, 2013 at 19:58
  • 1
    Hmm - I didn't read the question to mean that Firefox intentionally disregards keyboard shortcut defined by OS X - but perhaps that's what you are seeing based on the comments? I wonder if perhaps they implemented a shortcut remapping function? It's been a while since I've had the fox running. Choosing a command like ⌃⇧⌘Z works to make Command-Q insensitive for Mail and Safari - see this picture for how I set the shortcuts up. cl.ly/MDtE
    – bmike
    Commented Jan 16, 2013 at 20:00

16 Answers 16

250

Go to System Preferences, then Keyboard. Select Shortcuts. On the left pane, find Accessibility. Now on the right pane enable Invert colors and then click on the shortcut box to reassign the shortcut to Cmd+Q.

That's it. Now when you press Cmd+Q the colors of the screen will be inverted. Press it again to go back to normal colors. No more accidentally quitting applications (like closing over two hundred tabs on Firefox when trying to use Cmd+a or three dozen pdfs on Preview when trying to use Cmd+tab; last two things I did, never again.)

P.S. Whoever thought it was a good idea to use Cmd+Q to quit applications should go back to usability school.


There's also a nice plugin that you can use called Always Ask, which forces a prompt dialog before leaving Firefox.

17
  • 28
    Just registered here to upvote this answer. Cmd+Q is the equivalent of making an @ symbol on a German PC-105 keyboard layout. Switching between PC and Mac is driving me crazy because I keep closing the browser when logging in somewhere. Thanks for the brilliant idea with inverting colors.
    – q9f
    Commented Oct 14, 2016 at 7:57
  • 10
    I assigned it to "Switch to desktop 1". Since I'm not using this feature anyway, it effectively does nothing.
    – tiktak
    Commented Feb 11, 2017 at 5:53
  • 8
    Bonus point for using Invert colors as a warning. Great UX feedback.
    – Jason
    Commented May 23, 2017 at 2:54
  • 4
    I like your idea abou invert color , love it , it looks nerd
    – vanduc1102
    Commented Feb 9, 2018 at 10:45
  • 7
    You can also select Launchpad and Dock > Show Launchpad and set it to Cmd+Q. It's less annoying than your entire screen violently flashing when colors invert. Commented Aug 14, 2019 at 19:35
22

I have found a way to do this without having to change your volume or stuff like that when you press command+Q.

go to system preferences -> keyboard -> mission control -> "do not disturb".

Then just click the box and change it to: command+Q.

2
  • 1
    Nice trick. Just want to add - if still want to keep the ability to quit your app using shortcut, but there's no such preferences, then you can do so going to Settings -> Keyboard -> tab Shortcuts -> from left items list select App Shortcuts -> press + button, add your app -> Important! type exactly Quit and assign your shortcut. Enjoy! i.ibb.co/PzHvfRh/Screen-Shot-2019-09-04-at-10-38-12-AM.png Commented Sep 4, 2019 at 3:42
  • 1
    Works for me. This is better than the invert colors trick marked as the answer. Commented Nov 18, 2019 at 4:21
12

Sorry for digging up such old post but this idea may be useful.

In System Preferences - Keyboard create a new shortcut for the application you want to prevent quit. Search for the title of the quit command in the application's menu and enter the same exact as a Menu Title for the shortcut, then give a different shortcut.

Indeed, you don't have this issue with all applications but only browser and maybe one or two other apps.

7
  • 1
    Welcome to Ask Different! While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
    – grg
    Commented Jan 10, 2014 at 15:27
  • 2
    This solution doesn't apply to firefox. Firefox shows the new shortcut in its menu. But it doesn't work. cmd-q still closes the browser...
    – JerryWho
    Commented Jan 28, 2014 at 12:43
  • I followed this link that describes the same solution and that worked perfectly for me.
    – totymedli
    Commented Jan 12, 2015 at 0:57
  • I just added an "Option Q" shortcut for "Quit Firefox" as an Application specific (Firefox) shortcut for Firefox. In Firefox, my "Quit Firefox" menu item now shows opt Q, and cmd Q no longer quits the App, but opt Q does. You have to get the text of the menu item exactly right. Oh, I see, we're a couple years into the future here; with OS X 10.12.3. and Firefox 51.0. Commented Feb 8, 2017 at 21:03
  • 1
    Good fit for Safari (Safari respects the shortcut), and a sanity-saver for those of us who often hit CMD+Q instead of CMD+W. Commented Jul 18, 2017 at 5:21
8

Using KeyRemap4MacBook, you could add this to private.xml:

<item>
  <name>disable_command_q</name>
  <identifier>disable_command_q</identifier>
  <autogen>__KeyToKey__ KeyCode::Q, VK_COMMAND | ModifierFlag::NONE, KeyCode::VK_NONE</autogen>
  <autogen>__KeyToKey__ KeyCode::Q, VK_COMMAND | VK_SHIFT | ModifierFlag::NONE, KeyCode::Q, ModifierFlag::COMMAND_L</autogen>
</item>

Without | ModifierFlag::NONE the first autogen element would also disable for example ⌥⌘Q. The second autogen element changes ⇧⌘Q to ⌘Q.

There are also predefined settings that make sending ⌘Q require holding ⌘Q or pressing ⌘Q twice:

They are defined in custom_shortcuts.xml:

<item>
  <name>Hold Command+Q to Quit Application</name>
  <appendix>(You can adjust the threshold time of holding by</appendix>
  <appendix>"[Holding Key to Key] Holding Threshold" in Key Repeat tab.)</appendix>
  <identifier>remap.holdcommandQ</identifier>
  <autogen>__HoldingKeyToKey__ KeyCode::Q, VK_COMMAND | ModifierFlag::NONE, KeyCode::VK_NONE, KeyCode::Q, VK_COMMAND, Option::NOREPEAT</autogen>
</item>
<item>
  <name>Press Command+Q twice to Quit Application</name>
  <identifier>remap.doublepresscommandQ</identifier>
  <autogen>__DoublePressModifier__ KeyCode::Q, VK_COMMAND | ModifierFlag::NONE,
    KeyCode::VK_NONE,
    KeyCode::Q, VK_COMMAND
  </autogen>
</item>
2
  • 2
    On Karabiner Elements (the successor to KeyRemap4MacBook), there's a "complex modification" that can be downloaded online that achieve the same job: pqrs.org/osx/karabiner/complex_modifications/#command_q Changing the Safari option to Firefox or some other browser is just a matter of changing the app bundle regex inside the config JSON (which should be located at ~/.config/karabiner/assets/complex_modifications). Commented Dec 2, 2017 at 8:19
  • @GustavoBezerra can I please talk to you about doing this in Karabiner elements? Would you mind to join a chat room with me about it?
    – Arlen
    Commented Jun 10, 2022 at 8:04
6

You can disable Cmd + Q by using BetterTouchTool (a wonderful app) for Mac OS:

Go to Keyboard -> Add new shortcut or key sequence -> map Cmd+Q to "No Action"

enter image description here

4
  • 3
    You don't really modify the command, you just tell the system to prioritise another action. I find this incredibly hacky, as you can't re-use the command for anything else this way.
    – BlkPengu
    Commented Feb 14, 2021 at 21:11
  • @BlkPengu Apple is known for providing a consistent user experience. Commented Apr 24, 2023 at 4:41
  • @BlkPengu : the question is how to disable Cmd + Q, so I'm suggesting a solution. Meanwhile, you can still map Cmd + Q to something else if it's supported by BetterTouchTool
    – Dio Phung
    Commented Apr 24, 2023 at 22:33
  • @DioPhung I'm not saying your solution is invalid, just that I find it isn't elegant or pretty.
    – BlkPengu
    Commented May 3, 2023 at 20:21
5

QBlocker

QBlocker is a free and open source app by to solve this issue by requiring a user to hold down CMD+Q to quit all apps or just certain ones.

2
4

Use a keyboard remapper. There's a great GPL one for OSX (I use Keyremap4MacBook) Just map the command Q key combo to something that does nothing.

1
4

Now there is an item in the Chrome application menu "Warn Before Quitting" which does the trick for me.

Source: http://lifehacker.com/5784153/how-to-bring-back-the-hold-q-to-quit-prompt-in-google-chrome

2
  • 1
    They removed this feature a while ago.
    – Miscreant
    Commented Feb 5, 2018 at 8:44
  • @Miscreant As of 2020, it is there. Commented Oct 15, 2020 at 14:00
3

Not a direct answer to your question, but you can tell Firefox to automatically open your old windows when you launch it using the When Firefox starts option under the General preferences pane.

If you don't want to change your start screen just for the occasional accidental quit, there is also a command to do it: History menu -> Restore Previous Session.

1
  • 10
    Yes, but if there are many windows/tabs open, that can take quite a while, and some won't be able to recover their session/state completely. It also annoyingly restores all windows onto the current space, rather than the space they were on previously.
    – Ken
    Commented Jan 16, 2013 at 20:01
2

Go to System Preferences>Keyboard>Shortcuts then the application button on the left bar. Press the + button then Choose your application. Write "Quit (Application Name)" in the Menu Title Slot. Add your command to replace cmd-q and that's it.

1
  • 2
    This adds nothing that the other answers haven't already covered.
    – Tetsujin
    Commented Jan 14, 2016 at 17:31
2

The best way I found is next.

When I click Cmd + Q it locks my screen.

To achieve this:

  • Run System Settings
  • Select Keyboard in sidebar
  • Press Keyboard Shortcuts button
  • Select App Shortcuts in sidebar
  • Press on Plus (+) button
  • Write Lock Screen and assign it to Cmd + Q combination
  • Press Done button

Add Cmd+Q for Lock Screen Add a new item Lock Screen for All Applications You will see a new shortcut in the Apple logo menu

0

As you have seen, just setting a new keyboard shortcut in the System Prefs doesn't always work. It will change the shortcut shown in the menu but the application could still be listening for the Commmand+Q keypress. I've seen a few apps that do this. Even some will listen to keypresses that are not listed as shortcuts in the menu (Photoshop for example).

A 3rd party option is to use something like ControllerMate. It has the ability to remap any controller input (keyboard, mouse, trackpad, joystick, etc) and change what it does. I use it to do many remaps and run macro scripts. They can be set on a per-application basis or a global system-wide state.

Using ControllerMate, you could map Command+Q to do nothing then have Command+Option+Q call the Quit menu entry. Or you could get fancy and have Command+Q do nothing except if you press Command+Q again within 1/2 of a second then it would call the Quit menu.

ControllerMate is an amazing app. I've done many customizations like a "Boss/Spouse Mode" which is a single keypress that does the following

  • mutes the computer audio
  • pauses iTunes if it is playing
  • quits QuickTime and/or VLC if it is running
  • minimizes current Firefox windows and opens a new window to Google.com

Another suggestion (along with Henry's suggestion) is to use a session manager so if Firefox is quit by accident, you can restore easily. The built-in session manager is OK but you should also look at Tab Mix Plus. Not only does it give you amazing options for managing your tabs but its session manager is also great. I have many sessions saved and can pull them up quickly anytime in new windows.

1
  • 7
    $24.95 for an input remapper? That's hilarious.
    – Navin
    Commented Jan 20, 2016 at 1:53
0

Simply I have replaced the existing command with new one,

Ex. I replaced Quit command for Sublime Text for MAC,

I used to Add new shortcut and added new command alt+command+c

0

There is on solution not posted here that I thought should merit consideration. If you don't mind removing the command+q entirely from your computer you can effectively remap in Ukulele so that Command+Q execute another keyboard shortcut.

You could make it execute command+space or command+1 just assign it to something else.

There are positives and negatives to this approach but it should work.

0

Go to settings → Keyboard → shortcuts → App-keyboardshortcuts(on my mac: 'App-Tastenkurzbefehle') Press '+' Then add shortcut for the programm you wish to deactivate Command+Q. Afterwards type exectly the name of the menu point! Because my mac is geraman there is written 'Safari beenden'.

I prefer this solution because I still can close safari with a short cut but I am not doing it by accident. enter image description here

-1

use Switcher can prevent you to press cmd + q by mistake

1
  • 1
    Welcome to Ask Different! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – agarza
    Commented Aug 11, 2022 at 3:11

You must log in to answer this question.

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