AI Workshop: learn to build apps with AI →
UI APIs: Safari, warn before quitting

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


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.

Chrome and Firefox provide a nice, optional confirmation dialog when trying to close them:

Safari does not have it.

So I re-mapped the cmd-Q to cmd-option-Q.

Here is how to do it: open System Preferences and click Keyboard.

Click Shortcuts, then App Shortcuts:

Add a new shortcut, choose Safari, set the menu title to “Quit Safari”, and assign 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.

Lessons in this unit:

0: Introduction
1: Clipboard API
2: Scrolling
3: Console API
4: Speech Synthesis API
5: How to get the scroll position of an element in JavaScript
6: How to make a page editable in the browser
7: ▶︎ Safari, warn before quitting