82

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.

  • 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 Jan 15 '13 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 Jan 15 '13 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 Jan 16 '13 at 0:02
  • bmike: I was specifying the override for Firefox only, and including the app name in the menuitem override. – Ken Jan 16 '13 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 Jan 16 '13 at 20:00

13 Answers 13

120

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.

  • 12
    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. – Afr Oct 14 '16 at 7:57
  • 4
    I assigned it to "Switch to desktop 1". Since I'm not using this feature anyway, it effectively does nothing. – tiktak Feb 11 '17 at 5:53
  • 3
    Bonus point for using Invert colors as a warning. Great UX feedback. – Jason May 23 '17 at 2:54
  • 2
    I like your idea abou invert color , love it , it looks nerd – vanduc1102 Feb 9 '18 at 10:45
  • 1
    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. – SiddharthaRT Aug 14 at 19:35
7

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
    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). – Gustavo Bezerra Dec 2 '17 at 8:19
6

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.

  • 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 – Stanislau Baranouski Sep 4 at 3:42
  • Works for me. This is better than the invert colors trick marked as the answer. – Thomas Eding Nov 18 at 4:21
5

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.

  • 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 Jan 10 '14 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 Jan 28 '14 at 12:43
  • I followed this link that describes the same solution and that worked perfectly for me. – totymedli Jan 12 '15 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. – Wayfaring Stranger Feb 8 '17 at 21:03
  • 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. – AncientToaster Jul 18 '17 at 5:21
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.

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.

  • 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 Jan 16 '13 at 20:01
3

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

  • 1
    They removed this feature a while ago. – Miscreant Feb 5 '18 at 8:44
1

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.

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

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.

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.

  • 5
    $24.95 for an input remapper? That's hilarious. – Navin Jan 20 '16 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

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

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.

You must log in to answer this question.

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