tiny-pilot / tinypilot

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

Handling unidentified/death keys in the keyboard history UI #1747

Open jotaen4tinypilot opened 4 months ago

jotaen4tinypilot commented 4 months ago

I noticed one quirk in the UI, regarding the keypress history in the status bar. Note: this only affects the UI, not the backend or HID interface!

When the client machine is configured to use a keyboard layout that doesn’t provide a mapping for certain keys or key combinations, the keyboard history shows inconsistent results across browsers. From the view point of the target machine, however, things work as expected. So this issue is specific to using non-EN-US keyboard layouts.

I tested this on a MacOS machine with a customised keyboard layout, which doesn’t define a mapping for the alt+L key combination. So pressing alt+L on the client machine wouldn’t produce any character on the client machine itself. However, on the target machine, the alt+L combination may be well-defined, e.g. if the target machine uses a German keyboard layout where alt+L maps to the @ character. In this scenario, TinyPilot would forward the alt+L combination to the target machine, and produce the @ there.

In the TinyPilot’s web UI, however, I see these results in the status bar:

As stated in the documentation, the key property of the KeyboardEvent object may be Unidentified or Dead:

  • If the KeyboardEvent represents the press of a dead key, the key value must be "Dead".
  • If the key cannot be identified, the returned value is Unidentified.

For the keyboard history, we rely on that key property, which is why we see this.