Safari, warn before quitting
By Flavio Copes
Learn how to stop accidentally quitting Safari with cmd-Q by remapping its keyboard shortcut to cmd-option-Q from the macOS Keyboard settings.
Safari has no “warn before quitting” option, but you can stop accidental cmd-Q quits by remapping the Quit Safari shortcut to cmd-option-Q from the macOS Keyboard preferences. Here’s how I set it up.
I’m a browser hopper.
I use a browser for too many hours a day and sometimes I just have to change browser, just to try something new.
Today it was the turn of Safari.
I like Safari, a lot. It’s light, no-frills, and very fast.
However, while opening a new tab with cmd-W I accidentally pressed cmd-Q, quitting the browser. The two keys sit right next to each other, so this happens more often than you’d think.
Chrome and Firefox provide a nice, optional confirmation dialog when trying to close them:

Safari does not have it.
So I re-mapped cmd-Q to cmd-option-Q. Adding the option key makes the combination hard to press by accident, which is all I needed.
Remap the shortcut
macOS lets you override the keyboard shortcut of any menu item, in any app. We’ll use this to give Quit Safari a different shortcut.
Here’s how I did it: open System Preferences, and click Keyboard:

Click Shortcuts, then App Shortcuts:

Add a new shortcut, choose Safari and call the Menu Title “Quit Safari”, and add the new shortcut:

There it is:

Since this has the same title of the existing Quit Safari menu, the shortcut will now change:

No more accidental quitting. Pressing cmd-Q now does nothing in Safari, and quitting requires the deliberate cmd-option-Q combination.
One pitfall: the Menu Title must match the menu item exactly, character by character. If you type “Quit safari” with a lowercase s, macOS won’t find the menu item and the override does nothing. Open the Safari menu and copy the wording you see there.
This trick works for any app, not just Safari. You can use the same panel to defuse any shortcut you keep hitting by mistake.
Related posts about platform: