teleport
teleport copied to clipboard
Fix sticky windows key
This moves all keyboard handling in the useTdpClientCanvas
hook to a new KeyboardHandler
object which contains a couple of additional features that improve cmd+tab / alt+tab UX:
-
Key down events for cmd/alt are put into an internal cache and "withheld". They are then either a. Sent to the server when another key down/up event is encountered. Encountering another key event suggests that the original cmd/alt key down was a normal event, and should be treated as such. b. The cache is cleared
onfocusout
. This scenario is a proxy for a cmd+tab / alt+tab event, meaning the cmd/alt key down was never meant to be sent to the server. This is the change the fixes https://github.com/gravitational/teleport/issues/24342 -
Key up events for cmd/alt are delayed via a 10ms timeout. This was added because, empirically, I was able to hit cmd+tab in a way that both the cmd down and cmd up events were registered by the browser, thus popping up the windows-menu on the remote machine even though I'd switched to another window. These delayed events then either: a. Get sent to the server after the barely-noticeable 10ms delay b. Are cleared by an
onfocusout
which happens within 10ms, thus solving the problem I originally encountered above.
Changelog: Prevents the windows key from sticking and otherwise registering when cmd+tab-ing or alt+tab-ing away from the browser during desktop sessions.
Fixes https://github.com/gravitational/teleport/issues/24342
Depends on
- https://github.com/gravitational/teleport/pull/37962