tiny-pilot / tinypilot

Use your Raspberry Pi as a browser-based KVM.
https://tinypilotkvm.com
MIT License
2.99k stars 249 forks source link

In fullscreen mode, escape key exits fullscreen mode #522

Open mtlynch opened 3 years ago

mtlynch commented 3 years ago

Description

A user reported that hitting the escape key while in fullscreen mode causes fullscreen mode to turn off rather than just forwarding the key to the target machine as an "Escape" key.

What's the behavior that you expect?

TinyPilot forwards the escape key to the target machine and remains in fullscreen mode.

What's happening instead?

Hitting the "Escape" key causes TinyPilot to exit fullscreen mode.

What are the steps to reproduce this behavior?

  1. Open TinyPilot in Chrome
  2. Click on Commands > Fullscreen
  3. Hit "Escape"
mtlynch commented 3 years ago

One consideration here is how users exit fullscreen if we start absorbing the Escape key. Escape works cross-browser, so if we take that away, it might become hard to explain to users how to exit fullscreen.

Maybe we should treat two consecutive Escapes as "real" exit fullscreen.

djclueless commented 2 years ago

Here is a work around but... This solution will not work with every browser and it does not seem to work on non-secure sites.

Below is a detailed explanation of a work around which would require holding down ESC to exit full screen.

image

https://developer.mozilla.org/en-US/docs/Web/API/Keyboard/lock

https://wicg.github.io/keyboard-lock/#escape-key

# Lock keyboard and go full screen
navigator.keyboard.lock();
document.documentElement.requestFullscreen();
# Exit full screen and unlock keyboard.
document.exitFullscreen();
navigator.keyboard.unlock();

image

mtlynch commented 2 years ago

Thanks for investigating this! The keyboard.lock feels a bit too brittle at this point. It's strange that it doesn't work under HTTPS, since they don't seem to document that.