tiny-pilot / tinypilot

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

Offer a mechanism for press-and-hold a keystroke #821

Open mtlynch opened 2 years ago

mtlynch commented 2 years ago

When TinyPilot's backend receives a keystroke, it passes the keystroke and then sends an HID signal to release all keys.

The original intent was to prevent TinyPilot from thinking that keys are "held" when there's actually just latency on the network connection. It's possible that we can delete the release_keys logic and just wait for the client to send the signal for key release (keyup from the browser).

In any case, we should offer a way for users to press and hold a key, either by getting rid of the forced release_keys call or by adding an option to the on-screen keyboard to press and hold keys until they're released.

Steroid-Factory commented 2 years ago

Do you have a specific example of where and how this feature would be used? Would this feature affect both control_keys and hid_keycode on key down?

mtlynch commented 2 years ago

@Steroid-Factory - Thanks for checking it out!

Control keys currently have special behavior where they stay pressed until the user explicitly releases them. The idea is to change behavior so that all keys behave that way. Although my concern is that on connections with high latency, it will cause keys to repeat because maybe a user only presses the A key for 20 ms, but the "release" event takes 400ms to reach the backend, so there would be unexpected behavior.

The first step would be to test out what it's like if regular keys release like control keys under high latency. If it works fine, we just make the change. If it does, maybe we add intelligence so that if RTT for keystroke events is > 100ms, then we preserve the current behavior, and otherwise we wait for the user to explicitly release the key.