0

When my web page is requesting a full screen access using requestFullscreen from Fullscreen API, it can install a fullscreenchange event handler to be notified of going in / out of fullscreen. However this handler does not seem to be notified when user goes to fullscreen on his own (like pressing F11 in Chrome).

Is there a way how to be notified of this? My motivation is I would like to lock a pointer using Pointer Lock API once user presses F11 or uses the browser menu to switch to fullscreen.

Suma
  • 33,181
  • 16
  • 123
  • 191
  • Maybe you could register a window resize handler and check if the window size is the same as the screen size – ave4496 Feb 02 '17 at 14:37
  • 1
    You could register an event handler when the user presses F11 – Jonathan Newton Feb 02 '17 at 14:39
  • @JonathanNewton - like this :) `window.addEventListener('keyup', function(evt) { if (evt.key === 'F11') { /* fullscreen */ } });` – Walialu Feb 02 '17 at 14:43
  • F11 can easily change, or user can enter fullscreen from a menu, not by keyboard. Is there some cleaner and more general way? – Suma Feb 02 '17 at 14:46
  • @Ysragh yeah exactly! I'm not sure what the edge cases are but it seems like a winner – Jonathan Newton Feb 02 '17 at 14:46
  • @Ysragh While related, I do not think it is a duplicate. I would prefer to be notified, not to check. Still it is helpful, as if there is no such event, I can do a regular check on each frame and handle the change myself. – Suma Feb 02 '17 at 14:49
  • @Suma why not register the event then send it to a controller/message bus – Jonathan Newton Feb 02 '17 at 14:50

0 Answers0