Safari, warn before quitting

By

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:

Browser confirmation dialog asking "Quit and close tabs?" with Cancel and Close Tabs buttons

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:

macOS System Preferences window showing various preference panes including General, Desktop, Dock, and Keyboard

Click Shortcuts, then App Shortcuts:

Keyboard preferences with Shortcuts tab selected showing App Shortcuts category in left sidebar

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

Add shortcut dialog for Safari showing Application dropdown, Menu Title field, and Keyboard Shortcut field

There it is:

Keyboard shortcuts panel showing Safari section with Quit Safari command mapped to cmd-option-Q shortcut

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

Safari application menu showing Quit and Keep Windows command with cmd-option-Q keyboard shortcut

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: