Mac OS X Lion has a full screen feature that allows use of a single application window in full screen, i.e. without window title bar and constantly visible menu bar, on its own virtual desktop.
There's a problem however. If you press Escape while in full screen, and the application does not consume the event, you leave full screen. If we dismiss accidental key presses, this leaves programs that react to
keyUp, but neither of
It did take some time to determine the details in this question. Only @dpk figured it out in the last few comments to the question, the other comments and answers are mostly useless or just plain wrong.
The behavior described above appears with the "dialogs" on the Stack Exchange sites. They can be dismissed by pressing Escape. Since they only react to
keyUp, the key press itself is not consumed by the browser.
Please change, at least on OS X, the behavior of these dialog boxes: They should response to a different event. Alternatively, consume any Esc
keyDown in browser on Mac OS X, just to keep use of Esc from closing the dialog, while the dialog is visible.
IMO, it makes sense for a web site UI to prevent a web browser's default action on
keyPress (whatever that action is) if the
keyUp event on the web page is responded to. If limited to when such a dialog is visible, this shouldn't hurt any default functionality, especially since a repeated key press will perform the default action. But allowing the program to perform two unrelated actions when a key is pressed doesn't make any sense at all. So either remove the Escape functionality for dialog boxes, or also intercept the other events.
Early proof of concept
The following bookmarklet achieves the desired effect for the close dialog:
It'd be no sane one-liner if I'd include the flag popups, as their element IDs contain the related post's ID, and there is one for each answer.
Apparently, the proper way to handle this is
preventDefault. It appears to be something that is expected on anyone doing event handling: Handle all events that are triggered when a particular key is pressed so no unexpected side effects (such as the one presented here) occur. Therefore retagging to a bug.
User script fix
Here's a user script (4 lines of boiler plate code from here) that will fix this behavior:
It currently supports the following dialogs:
- Close question dialog
- Flag question and flag answer dialogs
Tested on Safari using NinjaKit only, but should be simple enough to work in other browsers. I'm not an experienced jQuery/user script programmer (as should be obvious), so feel free to fix bugs or suggest improvements. Please also provide the IDs of other dialogs that can be closed with Escape so they can be added to the script.
This post on Super User links to a few user script plugins, and contains another user script that will prevent Escape from leaving full screen mode in browsers on all sites.
I submitted a bug report to Apple against Safari 5 on February 24. It is tracked as Bug ID# 10926183 (
rdar://10926183). If you want to support this issue, please file bugs yourself and mention that they're duplicates of this issue. I don't think anything will come from this, since it's a bug resulting from carelessness by the web developers who implemented the event handling, but it's worth a try. In any case, this will only help with Safari. Consider submitting a similar issue to your favorite browser vendor.
Below is the description I submitted to Apple, Markdown formatted for MSO.
Safari leaves full screen mode in Lion even if some key events are handled
Safari leaves OS X Lion full screen mode on web pages handling only the keyUp event for the Escape key, which is often used by web page authors to provide some kind of keyboard navigation.
Steps to Reproduce:
- Open that web page document
- Go into full screen mode
- Press Escape
Safari does not leave full screen mode.
Safari does leave full screen mode.
Full screen mode is not left when the web page responds to keyDown instead. Full screen mode is only left upon releasing the key, even though this functionality seems to be triggered from the keyDown event.
Many web sites implement non-character key handling by registering a keyUp event handler. Pressing Escape to invoke some web site functionality will therefore both invoke the functionality and leave full screen mode, since no keyUp event can be triggered without keyDown.
Given the provided script code, the web page author intended for no default browser functionality to be invoked when the user presses the Escape key. Safari should not leave full screen mode in this situation even though technically it's an issue with the web page script programming not prevent default functionality of all events invoked when a key is pressed.