0

I have the code below for identifying when the user press the ESC key. It works fine in Safari when the browser is not in fullscreen mode. But I can't make it work when it is in fullscreen mode. Any solution to this?

PS: it must work for the most used browsers.

jQuery(document).keyup(function(e) {
  if (e.keyCode == 27) {
    if (Math.round((document.getElementById("canvas").style.width.match(/\d+/g).map(Number) * 1.45)) > screen.availWidth) {
      alert('Fullscreen');
    }
  }
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Julio S.
  • 944
  • 1
  • 12
  • 26
  • Checking fullscreen: https://stackoverflow.com/questions/16755129/detect-fullscreen-mode – Geert-Jan Mar 08 '19 at 19:05
  • That's because you're using `.keyCode`, which is now deprecated. https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode – jstarnate Mar 08 '19 at 19:24

0 Answers0