-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
Description
While PR #180692 successfully fixed issue #162305 (where the web embedder synthesized key up events too eagerly for normal typing / game control), a limitation remains when the Meta key (Cmd on Mac) is involved.
Because the key guard mechanism in the web embedder is still required and active when the Meta key is pressed, pressing multiple non-modifier keys simultaneously alongside it causes the guard to misbehave. Only the last pressed non-modifier key sends repeated events, which leads the framework to eventually (and incorrectly) synthesize key up events for the other physically held non-modifier keys.
Note: This specific behavior was isolated to the Meta key during debugging in the PR, rather than all modifier keys.
Steps to reproduce
Using the KeyboardListener or Focus.onKeyEvent APIs on a Web build (JS or WASM):
- Press and hold the
Cmd(Meta) key. - Press and hold
[j]. - Press and hold
[k]. - Wait for over 1.5 seconds (or
> _kKeydownCancelDurationMac).
You may use the sample app from the linked issue to debug this too.
Expected results
The framework should recognize that Cmd, j, and k are all still actively pressed. No KeyUpEvent should be fired until the user physically releases the keys.
- Expected event stream:
Cmd down,j down,k down
Actual results
The web embedder synthesizes a premature key up event for the first non-modifier key (j), even though the user is still physically holding the key down.
- Actual event stream:
Cmd down,j down,k down,j up(synthesized)
Context and Related Issues
- This is a known limitation documented during the review of PR Fix issue where web embedder is synthesizing key up events too eagerly #180692: [Fix issue where web embedder is synthesizing key up events too eagerly](Fix issue where web embedder is synthesizing key up events too eagerly #180692).
- Related to the original Issue [BUG] [WEB]
KeyboardListener's andFocus.onKeyEvent'sKeyUpEventdo not work correctly in JS and WASM builds #162305: [BUG] [WEB]KeyboardListener's andFocus.onKeyEvent'sKeyUpEventdo not work correctly in JS and WASM builds.
A potential workaround discussed was to delay the synthesizing of non-modifier keys until the meta-key is released entirely, but this risks keeping the framework out of sync for non-modifier keys until the modifier is released. Another suggested idea was discussed where receiving repeated key-up events for any non-modifier key would also delay (reset guards) the synthesizing of all non-modifier key-up events. Both ideas are only slightly better than the current behavior, as its impossible to get a "perfect" solutions (because browser is not sending the key-up events at all when meta key is involved).