Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BUG] [WEB] KeyUpEvent is synthesized too eagerly when combining the Meta key with multiple non-modifier keys #182775

@O-Hannonen

Description

@O-Hannonen

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):

  1. Press and hold the Cmd (Meta) key.
  2. Press and hold [j].
  3. Press and hold [k].
  4. 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

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.team-webOwned by Web platform teamtriaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions