Disabling the ESC Key in Fullscreen Mode

Over-The-Shoulder Quick Tip

Q: If you have a fullscreen SWF how do you prevent the display from returning to normal size display when the user presses the ESC key? An example case where this would be useful is pausing a fullscreen game and displaying an in-game menu.

A: I thought overriding the default behavior might pose a security risk, however it is not restricted. Listen for the associated keydown event for ESC and call preventDefault() on it.

You can prevent the default behavior for some other events as well. You can prevent input text from appearing as the user types, prevent double-click text highlighting, and more. To determine if an event has a default behavior that can be prevented check if the Event.cancelable property is true.

Adobe Help Reference Doc for the preventDefault() method: LINK

Leave a Reply