I need to show Fullscreen key combination for various environment in a message to User on my website.
That needs to be detected based on environment. For eg Safari+windows = "F11" and Safari+mac = "cmd+shift+F"
I need to show Fullscreen key combination for various environment in a message to User on my website.
That needs to be detected based on environment. For eg Safari+windows = "F11" and Safari+mac = "cmd+shift+F"
Instead of showing the shortcut for various browser/OS combinations, why not use the fullscreen api? On MDN they give an example that binds an event to the toggle-fullscreen:
var videoElement = document.getElementById("myvideo");
function toggleFullScreen() {
if (!document.mozFullScreen && !document.webkitFullScreen) {
if (videoElement.mozRequestFullScreen) {
videoElement.mozRequestFullScreen();
} else {
videoElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else {
document.webkitCancelFullScreen();
}
}
}
document.addEventListener("keydown", function(e) {
if (e.keyCode == 13) {
toggleFullScreen();
}
}, false);
Thank you, that is a good solution. However, my RIA has a texbox for user entry on one page as well as it needs to go Fullscreen on launch. The (Element.ALLOW_KEYBOARD_INPUT) works well for all the browser's except Safari. For safari we are moving exiting user from fullscreen and want a graceful message to show them how to go fullScreen back once they are done with entering text. For that I need to capture various environment key combinations.