-3

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"

Sidharth
  • 5
  • 1

2 Answers2

0

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);
NoBugs
  • 9,310
  • 13
  • 80
  • 146
  • 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. – Sidharth Feb 24 '13 at 04:40
0

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.

Sidharth
  • 5
  • 1