Can I globally change the cmd-Q shortcut to require holding for two seconds, like the option in Chrome?

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)?


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.


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.)


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.


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