Skip to content Skip to sidebar Skip to footer

Onclick Element Simulate Esc Key

I have the following situation: When the user clicks on a link, through Javascript Esc key should be triggered. So to be able to explain it better I have the following code so far

Solution 1:

JavaScript can't trigger OS-level events from the browser window, except the cases when it is natively supported by the browser via special functions or APIs. You can't send a system-level keyboard event with ESC key to close fullscreen mode, or, say, launch system help with F1.

Instead you may use Fullscreen API which is supported by major browsers:

if (document.exitFullscreen) {
    document.exitFullscreen();
} elseif (document.mozCancelFullScreen) {
    document.mozCancelFullScreen();
} elseif (document.webkitCancelFullScreen) {
    document.webkitCancelFullScreen();
}

MORE:http://www.paulund.co.uk/javascript-full-screen-api

Post a Comment for "Onclick Element Simulate Esc Key"