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 settings. 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. Chrome has a “Warn Before Quitting” item in its application menu, and Firefox has a “Confirm before quitting with ⌘Q” checkbox in its settings.

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.

Open System Settings from the Apple menu and go to Keyboard. Click the Keyboard Shortcuts… button, then pick App Shortcuts in the sidebar. On macOS versions before Ventura the same panel lives in System Preferences → Keyboard → Shortcuts → App Shortcuts.

Click the + button to add a shortcut. In the dialog, set Application to Safari, type Quit Safari as the Menu Title, and press the new key combination in the Keyboard Shortcut field, then confirm.

The new shortcut shows up under a Safari group in the App Shortcuts list. Since it has the same title of the existing Quit Safari menu item, macOS replaces the shortcut of that menu item: open the Safari menu and you’ll see cmd-option-Q next to Quit Safari.

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.

Want me to talk about your product? You can sponsor this site.

~~~

Related posts about platform: