Don't exit full screen when pressing escape in apps like Safari on Lion
Solution 1
Try OptionEsc, which worked for me.
Solution 2
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
- Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Install cask
brew tap caskroom/cask
- 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:
- Open karabiner-elements and go to "Complex modifications" tab
- Click "Add rule" button, then "Import more rules from the Internet"
- Import modification "Don't exit fullscreen when pressing ESC in Safari"
Solution 3
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 4
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 pressingCtrl-.
translates toCtrl-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.
Solution 5
Your possible options include:
Set alternative shortcuts for the other functions, because ESC is reserved by the OS and Browser.
Adjust the source / assembler machine code to rebind the ESC key of the OS and Browser.
File the bug/feature request against application developer (i.e. Google spreadsheets) to consume ESC event instead of letting it through.
File a bug with Apple, because the applications were here first, and Apple re-purposed the key without cause.
Related videos on Youtube
Fadi
Updated on September 18, 2022Comments
-
Fadi over 1 year
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.
-
HikeMike almost 13 yearsPressing
Esc
where it has a different effect (e.g. aborting page loading) does not exit full screen. -
Tamara Wijsman over 12 years@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?
-
HikeMike over 12 years@Tom Please explain; what other functions?
-
Tamara Wijsman over 12 years@DanielBeck: It's listed in the question:
ESC
is used for other functions as well. -
HikeMike over 12 years@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.
-
Tamara Wijsman over 12 years@DanielBeck: The users says "other functions", and that's enough.
-
peelman over 12 yearsI, too, am curious what other functions are being trampled on here. And I will say that Full Screen is a new feature, and as with any new feature, there are going to be usability issues. You should file this as a bug with Apple (bugreport.apple.com), as I'm not sure its the intended behavior.
-
Admin over 12 yearsMajor problem for terminal emulators. It is very common to use the escape key in a terminal session to go back to the previous host screen or exit what you are doing. Apple needs to provide a way to disable escape so other programs can use it.
-
HikeMike over 12 yearsThe user so far failed to provide any example where
Esc
would produce any other effect and exits full screen anyway. The "examples" in @AJACs' answer don't work either, instead showing a sensible behavior in all cases. Down-voting. -
HikeMike over 12 years@Rich As is obvious from Terminal's behavior, programs can disable
Escape
for leaving full screen. iTerm2 also does not close full screen withEscape
. What, in detail, are you referring to? -
HikeMike over 12 years@TomWijsman Interesting. All examples brought forth so far does not work. Even though there are already two non-answers with "examples" where
Escape
behavior are alleged to be broken, none of them actually behave as described. There's a reason I asked for concrete examples right from the start: There just aren't any. -
Fadi over 12 yearsAccidentally 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.
-
internetdotcom over 12 years@Daniel Beck: You're ignoring the scenario where pressing escape causes windows to leave full screen mode if you tap it accidentally. There's no reason for that. Why are you so violently opposed to this question and a request for a solution?
-
internetdotcom over 12 yearsScenario: A web page uses Javascript to monitor the escape key, used to close divs and the like. Tapping escape leads to Javascript processing the event AND Lion's misbehavior. Is that sufficient? It is a UI mistake to trigger leaving full screen mode on escape.
-
HikeMike over 12 years@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.
-
internetdotcom over 12 years@Daniel Beck: Here ya go: dpk.net/demonstration-of-escape-problem-in-lion.html . Full screen Safari and then go to that page, click the button, and hit escape to clear the fake dialog. Sorry for the 'tude earlier, bad day.
-
HikeMike over 12 years@dpk Hmmm... OK. You could use
.keydown()
andreturn false;
, then it'd be no issue. But this is finally a working example that doesn't play well with fullscreenEsc
, at least. -
internetdotcom over 12 yearsI've edited the post to add this example. Hopefully we'll/someone'll find a way to work around Apple's error here.
-
HikeMike over 12 years@dpk I guess I just admitted defeat :-)
-
Aykut Aras over 9 yearsI found ctrl+esc works gmail's hangouts windows close. It may work for other websites too.
-
Fadi almost 3 yearsWell, 10 years in and this is still a problem!
-
-
peelman over 12 years#1 I can get behind. #2 is almost tongue-in-cheek to the point of laughter.
-
Tamara Wijsman over 12 yearsWell, your mileage may vary.
-
HikeMike over 12 yearsAnd again, pressing
Escape
to cancel dialogs does not exit full screen. -
HikeMike over 12 yearsPressing
Escape
in Terminal does not exit full screen. -
HikeMike over 12 yearsUsing
Escape
to cancel a drag does not exit full screen. Have you even tried it before posting these claims? -
HikeMike over 12 yearsUsing
Escape
in Reeder to e.g. return from an article web page to the RSS item does not exit full screen. IfEscape
is not used for such an action, it exits full screen. As in ALL OTHER PROGRAMS. -
HikeMike over 12 yearsFunctions using
Escape
are not usually available from the menu bar, andEscape
does not trigger menu items as is obvious from the missing "flash" highlighting the menu bar item containing the triggered item. -
internetdotcom over 12 years#4 File a bug with Apple, because the applications were here first, and Apple re-purposed the key without cause.
-
HikeMike over 12 yearsRelated request on MSO, works without jQuery.
-
HikeMike over 11 yearsIt doesn't trigger actions associated with the Escape key either, e.g. aborting Safari web page loading.
-
R.P. over 10 yearsfor convenience's sake, I uploaded this to userscripts: userscripts.org/scripts/review/178642
-
Holene almost 10 yearsAny experience installing this on Safari for Mavericks?
-
Gene Childs over 9 yearsYeah 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...
-
HikeMike over 9 years@foregon I'd expect page event handling to have absolutely no effect while you're in the address bar.
-
Manoj Sheth about 7 years⌘ + . exits full screen mode for me in Opera, so this is a no go :(
-
Toni almost 6 yearsworks with tampermonkey, edited the script/response to support https:// as well.
-
LinusGeffarth over 4 yearsAwesome, this works well in Safari 13. Thanks for sharing!
-
TimNode about 3 yearsThis is kinda hard to get the hang of but seems like the only solution that works well in all situations