Don't exit full screen when pressing escape in apps like Safari on Lion

Solution 1:

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.

Solution 2:

Try OptionEsc, which worked for me.

Solution 3:

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"