treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Disable F11 keyboard shortcut in IE8

  • Hi There,

    I'm trying to disable F11 key press in my application.

    Previously i was using the below code to throw a JavaScript alert when user hits F11 key.
    	if (e.keyCode == 122 && e.type == "keydown")
    {
    alert ("F11 is not currently supported by this application.")
    e.keyCode = false;
    e.cancelBubble = true;
    e.returnValue = false;
    return false;
    }

    The above code works fine when i was using IE6.

    When i start using IE8, it did not work.
    I tried to use e.preventDefault() inside the above if loop, but it did not work as expected in IE8.

    Still the Browser goes into Full Screen Mode (which i don't want to do)

    Please provide your valuable thoughts.

    Thanks!!!

  • F11 is the kind of standard functionality (just like right-clicking) that you should never take away from the user.
  • @sneff - Thanks for the suggestions. But restricting the F11 key is the ask from the team. Previously we were able to suppress in IE6. But the same code doesn't work.

    Anyone Please provide some solution on the same.
  • What @Senff was hinting at is that it is not acceptable for a site to impose those types of restrictions on a user's OS. Modern browsers are designed to actively prevent it, and they should - it's a security risk.

    You should be looking for a different solution to whatever problem you're trying to address.
  • Try using JavaScript to detect when the viewable browser size reaches the same size (within a few pixels) as the actual screen size. Then you could throw up your alert to tell the user to exit full screen mode.
  • I actually meant "a different solution" to the larger problem (if there is one), i.e., whatever it is that goes wrong in fullscreen mode -- not just some other way to try to take over the user's preferences.