In OS X Lion, pressing the ESC key exits full screen mode. Unfortunately, and especially when using Safari, ESC is used for other functions, such as in Javascript keystroke event handling. I don't want Lion to exit full screen mode when pressing escape, but I can't find a place to disable that functionality.

I already know the keyboard shortcut to Enter/exit full screen mode (Cmd-Ctrl-F). I want to disable the ESC shortcut. I've been Googling, but cannot find any answers.

  • 2
    Pressing Esc where it has a different effect (e.g. aborting page loading) does not exit full screen.
    – Daniel Beck
    Commented Aug 2, 2011 at 15:55
  • @Daniel: But that doesn't necessarily apply to any other functions. Is this actually a wide spread OS X Lion problem? Why are there so few people that are actually experiencing this? Commented Aug 29, 2011 at 15:00
  • 1
    @Tom Such as? The user doesn't say, and neither do you. I could imagine all those functions overriding the full screen mode shortcut when used by e.g. consuming the event, but without more examples, I can't say for sure.
    – Daniel Beck
    Commented Aug 29, 2011 at 15:24
  • 13
    Accidentally hit enter There are many web pages where ESC is used to close a modal window, for example: ericmmartin.com/projects/simplemodal-demos Click Demo on the page to display a modal window. Press ESC to close the modal. Safari is aware that there is a modal window, and doesn't exit full screen. Press ESC again and Safari exits full-screen mode. Often I press ESC several times to ensure something gets closed. I don't want Safari to exit full-screen mode when that happens. There is already a key command to exit full-screen. ESC shouldn't be used.
    – Fadi
    Commented Sep 26, 2011 at 21:44
  • 1
    @dpk Link to a demo web page, please. Since none of the examples mentioned so far have this issue when I tested them, I don't believe that without steps to reproduce the issue. In fact, Fadi's example above contradicts your comment.
    – Daniel Beck
    Commented Nov 3, 2011 at 16:00

13 Answers 13


Try OptionEsc, which worked for me.

  • 1
    It doesn't trigger actions associated with the Escape key either, e.g. aborting Safari web page loading.
    – Daniel Beck
    Commented Jan 3, 2013 at 15:20
  • Awesome, this works well in Safari 13. Thanks for sharing! Commented Dec 30, 2019 at 11:26
  • This is kinda hard to get the hang of but seems like the only solution that works well in all situations
    – TimNode
    Commented Mar 5, 2021 at 17:12
  • @DanielBeck There're usually other key bindings for those actions, e.g. aborting the loading of a page can be done by pressing cmd + . and the tab key can be used to deactivate the address bar.
    – Xavier
    Commented Feb 26, 2023 at 12:44

I didn't find an answer for macOs Sierra and higher. So that's how i solved this issue.

As it has been already suggested i've remapped ESC to ⌥ + ESC. It does the job and even some other functions assigned to the key works. You will be able to exit fullscreen videos on some sites, but it will not abort page loading.

First you need to install Karabiner-elements to be able to remap keys

  1. Install brew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Install cask brew tap caskroom/cask
  3. Install karabiner-elements brew cask install karabiner-elements

I've created custom "Complex modification" specifically for this problem. To install this modification you have to:

  1. Open karabiner-elements and go to "Complex modifications" tab
  2. Click "Add rule" button, then "Import more rules from the Internet"
  3. Import modification "Don't exit fullscreen when pressing ESC in Safari"

For web browsers, and specifically for use of sites with behavior that enables or requires use of the Escape key while not preventing closing of full screen (like Stack Exchange sites), you can use the following user script:

// ==UserScript==
// @name           Keep Full Screen
// @namespace     http://superuser.com/q/315949
// @description    Prevents Escape key from leaving full screen.
// @include      http://*
// ==/UserScript==
document.onkeydown = function (evt) {
    if (evt.keyCode == 27) evt.preventDefault();

To run this in browsers, use any user script engine for your browser.

  • For Safari 5, you can use the Safari extension NinjaKit (on GitHub). This is what I use.
  • For Chrome, you can use its NinjaKit variant.
  • For any other Safari on OS X, you can use the SIMBL plug-in GreaseKit. Not sure how up to date it is though.
  • for convenience's sake, I uploaded this to userscripts: userscripts.org/scripts/review/178642
    – coffeejunk
    Commented Sep 26, 2013 at 12:18
  • Any experience installing this on Safari for Mavericks?
    – Holene
    Commented Jun 10, 2014 at 9:12
  • 2
    Yeah this doesn't work for me, I'm in Yosemite Beta 5 with Safari 8.0 (10600.1.25) at the time of writing, and using NinjaKit in Safari as the userscripts engine. Escape key keeps on breaking full screen and for me it's happening when I'm in address bar and press Esc while in it. (it has a few useful functions when editing text in it...) I'm assuming GreaseKit no longer works given it's dated to 2009 and a quick google seems to indicate it doesn't work anymore. Any ideas? So frustrating, no wonder Chrome is the go-to primary browser, even on Apple's own operating system...
    – user78017
    Commented Oct 8, 2014 at 7:29
  • @foregon I'd expect page event handling to have absolutely no effect while you're in the address bar.
    – Daniel Beck
    Commented Oct 8, 2014 at 12:18
  • works with tampermonkey, edited the script/response to support https:// as well.
    – Toni
    Commented Jul 2, 2018 at 16:47

Most situations native to OS X accept both Escape and Cmd-. to abort, e.g. file dialogs, Safari loading, dragging elements around, etc.

Notably absent from that list is, of course, leaving full screen mode.

So you could just learn to press Cmd-. instead of Escape to avoid this situation altogether. Or you can teach your computer to do it for you: An at least somewhat sane solution is to use e.g. Butler's Keystrokes item to map Escape to Cmd-.:

  • Open Butler's configuration page
  • Select any container, e.g. Hidden, click + » Smart Item » Keystrokes
  • On the Keys tab, press Cmd-. to use this as the resulting keystroke when activating this item
  • On the Triggers tab, select the Hot Key input field and press Escape. Ignore the warning that basically states you're insane.
  • Remember to add e.g. Terminal to the exceptions list — it totally ignores Escape for leaving full screen, but pressing Ctrl-. translates to Ctrl-C!

In some situations, things will misbehave. Remapping the key to what's usually an equivalent keyboard shortcut is a sledgehammer solution. Quick Look, for example, doesn't handle Cmd-. (and therefore the remapped Escape for closing file previews); renaming files in Finder cannot be aborted anymore using Escape, nor selections e.g. in Finder be cleared.

In limited testing, I found no situation where pressing Cmd-. actually leads to undesirable actions being performed, but be aware that these probably also exist.

  • Of course, you could completely ignore all Escape keypresses like this, but that'll lose a good bit of functionality...
    – Daniel Beck
    Commented Nov 23, 2011 at 11:34
  • ⌘ + . exits full screen mode for me in Opera, so this is a no go :(
    – Andy E
    Commented Mar 1, 2017 at 10:22

EASY, found it! KeyboardMaestro with 2 actions

When pressing "ESC" Simulate pressing (instead): - "CMD+." - THEN also "ALT+ESC"

You need both, because some app react only to one order or the other (sometimes to none, then nothing possible) -- >this way most apps will do like an "ESC" in their context, but you will never get exited from the full screen mode


Your possible options include:

  1. Set alternative shortcuts for the other functions, because ESC is reserved by the OS and Browser.

  2. Adjust the source / assembler machine code to rebind the ESC key of the OS and Browser.

  3. File the bug/feature request against application developer (i.e. Google spreadsheets) to consume ESC event instead of letting it through.

  4. File a bug with Apple, because the applications were here first, and Apple re-purposed the key without cause.

  • 3
    #1 I can get behind. #2 is almost tongue-in-cheek to the point of laughter.
    – peelman
    Commented Sep 7, 2011 at 19:05
  • Well, your mileage may vary. Commented Sep 7, 2011 at 23:30
  • Functions using Escape are not usually available from the menu bar, and Escape does not trigger menu items as is obvious from the missing "flash" highlighting the menu bar item containing the triggered item.
    – Daniel Beck
    Commented Sep 18, 2011 at 14:50
  • #4 File a bug with Apple, because the applications were here first, and Apple re-purposed the key without cause. Commented Nov 5, 2011 at 16:12

Just to flesh out the description a bit more.

ESC is used to cancel a drag, esc is used to cancel a dialog box, esc is used during a drag to cancel a move/copy, esc is used in terminal in VI to cancel an editing command

So, there are numerous uses. It is a weird oddity that Apple has this cancel full screen mode when that is possible by ctrl-cmd-F and the upper right icon.

This seems to be on an app by app basis Mail and Safari and other iLife items will exit full screen. iTunes stays full screen.

Reeder ignores the esc for the purpose of Full window control, and does other appropriate things for the program. Evernote does not even have a cmd-F or ctrl-cmd-F for window control, its the icon and the esc key.

You can't seem to map esc by itself to some non-harmful nonsense action in the keyboard control panel.

  • 1
    In Safari, mapping the Escape key to a benign function doesn't seem to be a solution. Regardless of the action, it will still drop out of Full Screen.
    – peelman
    Commented Sep 7, 2011 at 19:02
  • And again, pressing Escape to cancel dialogs does not exit full screen.
    – Daniel Beck
    Commented Sep 18, 2011 at 14:38
  • Pressing Escape in Terminal does not exit full screen.
    – Daniel Beck
    Commented Sep 18, 2011 at 14:39
  • Using Escape to cancel a drag does not exit full screen. Have you even tried it before posting these claims?
    – Daniel Beck
    Commented Sep 18, 2011 at 14:39
  • Using Escape in Reeder to e.g. return from an article web page to the RSS item does not exit full screen. If Escape is not used for such an action, it exits full screen. As in ALL OTHER PROGRAMS.
    – Daniel Beck
    Commented Sep 18, 2011 at 14:42

It looks like you're using JQuery. In that case:

Listen for keydown events (keypress and keyup won't work) on the document with keyCode 27, and when the event fires call e.preventDefault().

$(document).bind('keydown', function(e) {

    if (e.keyCode === 27) { // Escape key
        // Other code goes here    


I decided to have esc routed to alt/option + esc. For the most part, this lets me get out of YouTube vids, and if you have a Squarespace account, it lets you login without getting out of full screen.

  • Download and install Karabiner.
  • Go to the right most "Misc & Uninstall" tab.
  • Click on the button that says "Open private.xml".
  • Download the private.xml file from here
  • Replace the original "private.xml" file in Finder with the downloaded file. Voila!

Use BetterTouchTool or KeyboardMaestro or something similar to remap Esc to ⌥ + Esc.


After some desperate search for the solution, I consign Safari to a separate virtual desktop with Mission control. This mitigates the ESC problem and is by far the best approximation to a fullscreen Safari window.

Bonus space if you hide the Dock.


This is the same as the @aditya-srinivasan answer targeting Opera

<?xml version="1.0"?>
  <!-- ============================================================ -->

    <name>Escape to Option + Escape on Opera</name>
    <autogen>__KeyToKey__ KeyCode::ESCAPE, KeyCode::ESCAPE, ModifierFlag::OPTION_L</autogen>
  <!-- ============================================================ -->

See @aditya-srinivasan answers on the downloading https://pqrs.org/osx/karabiner/index.html.en


Use the combination ⌘+esc (cmd+esc) (⌥+esc (opt+esc) also works)

This allows the webpage to "esc" whatever is selected (ie: the editing of cells in Google Sheets) without affecting the browser.

Works on Ventura 13.2 with Safari 16.3.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .