40

Many, many times, I accidentally press +Q when I meant to close a tab or window, or switch applications. When I saw the option in Google Chrome to require the shortcut to be held, I was overjoyed. Problem is, I use Safari.

So, in short: How can I make the "hold command-Q" shortcut universal across all of my applications (or at least Safari)?

6
  • 4
    Where is this setting you speak of?
    – Senseful
    Mar 22 '12 at 20:02
  • Awesome question Timothy!!
    – daviesgeek
    Mar 22 '12 at 20:03
  • 3
    @Senseful It's counterintuitively under the Chrome menu, rather than Chrome preferences.
    – Tuesday
    Mar 22 '12 at 20:04
  • 4
    "Warn Before Quitting."
    – Tuesday
    Mar 22 '12 at 20:04
  • Great question, leading to very useful answers! Mar 29 '12 at 21:33
9

Douglas Teoh has made an app called SlowQuitApps, that does exactly this.

An OS X app that adds a global delay of 1 second to the Cmd-Q shortcut. In other words, you have to hold down Cmd-Q for 1 second before an application will quit.

When the delay is active, an overlay is drawn at the center of the screen.

1
  • 3
    I can't believe people are actually writing apps to achieve this. Way to go “intuitive Apple!”
    – Stewart
    Apr 1 '16 at 12:05
19

Here's a partial solution for starters:

Preventing accidental quitting in Safari (or any specific application)

Simply set up an unusual keyboard shortcut for the "Quit Safari" menu item in Keyboard preferences.

This will disable the standard Q shortcut, so accidentally hitting it doesn't make a difference — and you have to think before you quit!

(Unfortunately, I haven't found an easy way to do this for every application, without entering each one manually.)

2
  • Very nice, I have implemented, and upvoted! As an aside, by default ⌥⌘Q is "Quit and discard Windows". Mar 29 '12 at 21:37
  • Oh drat, you're right. Well, ⌃⌘Q or something else should work too — however I find ⌥⌘Q a little harder to hit by accident.
    – jtbandes
    Mar 29 '12 at 21:58
14

Continuing on jtbandes' solution, once you have remapped the standard Quit command to a different keystroke (yes, sadly, you need to remap it manually for every application you are worried about accidentally quitting), you can create a service in Automator that takes no input. It should have a single action: Run AppleScript. The script is:

tell application "System Events"
    set theName to name of the first process whose frontmost is true
end tell
tell application theName
    display dialog "Are you sure you want to quit?"
    quit
end tell

You then save that service (I called mine "SafeSave"), and assign the service the keystroke Q. You have thus reclaimed the standard keystroke.

5
  • 1
    Clever. Hm, I suppose one could write a script to activate on cmd-Q which would then require another cmd-Q to complete the quit...
    – Tuesday
    Mar 23 '12 at 0:42
  • Clever, indeed! Have an up vote! :-)
    – Asmus
    Mar 23 '12 at 8:37
  • Very nice, I have implemented, and upvoted! Mar 29 '12 at 21:34
  • This works well. Both Automator Workflows and Quick Actions show up as services (this bit had me confused as normally I don't use Automator). The only issue is that every application which you don't want to quit on Command-Q requires its own entry. But there's lots of single window applications which can be quit with straight Command-Q so in a way it's the best of both worlds. Previously I had Keyboard Maestro set up with a double tap Command-Q to quit which worked well but is non-native. Sep 24 at 9:23
  • Unfortunately this doesn't work with Fluid Browser apps. I believe it's because they are unsigned. While I have the setup working for my other applications with Fluid Browser apps, this error message is returned: "The action "Run AppleScript" encountered an error: "Not authorised to send Apple events to System Events." If anyone has any idea how to fix this, I'd be delighted to try. I've dug deep in the research here but without success: felix-schwarz.org/blog/2018/06/… mjtsai.com/blog/2018/08/23/apple-events-usage-description Sep 24 at 12:26
8

Another option is to use Karabiner with the following XML:

__HoldingKeyToKey__ KeyCode::Q, VK_COMMAND | ModifierFlag::NONE, KeyCode::VK_NONE, KeyCode::Q, VK_COMMAND, Option::NOREPEAT

3
  • While the application has been renamed to Karabiner, this answer worked great for me on 10.10 and was completely free. Apr 22 '15 at 20:28
  • Can you describe how to use this? I have Karabiner installed but I don't know how to use your command. Apr 17 '18 at 11:07
  • @ManuelMauky Go to complex modifications page of Karabiner and click "Import" button near "Prevent unintended command-q (rev 2)".
    – Utku
    Jul 4 '19 at 20:07
1

CommandQ ($4.00) does exactly this. It's very customizable and has a nice GUI, though I haven't used it personally. It seems to fulfil the requirements of this question.

-2

I don't believe that's possible.

You must log in to answer this question.

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