Skip to content

Flutter Web misses rapid shortcut presses #95474

@luigi-rosso

Description

@luigi-rosso

Tested in 2.8.0 and master.

I'm using Shortcuts and Actions to test triggering custom actions via keybindings. The details below are regarding a PasteAction via a PasteIntent when pressing command v, but the general problem/root cause is due to Flutter Web's keyboarding binding and happens when listening to HardwareKeyboard or RawKeyboard events too.

On the Web, Flutter does this debounce trick to synthesize key-ups on modifier key combos (I remember fighting this 6 years ago, can't believe browsers still don't report key-ups in these cases). In combo with ignoring presses without a release, Flutter web misses reporting combos like (note these are quick, time is important as the keyguards have 1-2s durations):

0ms: Press CMD
200ms: Press V
400ms: Release V
600ms: Press V
800ms: Release CMD

Which should result in two Paste actions, instead only generates one because the release for V isn't seen (browser issue). Flutter web will report:

0ms: Press CMD
200ms: Press V
800ms: Release CMD
2200ms: Release V (Flutter's keydown guard on mac is 2s)

Our workaround takes a different approach, we will always report keydowns when modifiers are pressed and instead of synthesizing on a timer, we synthesize key-ups for all known pressed keys when the modifier is finally released. Rive's fix will report:

0ms: Press CMD
200ms: Press V
600ms: Press V (we could also synthesize a key-up right before this, but we currently don't).
800ms: Release V (sent just before CMD as we see V was pressed while CMD was down, so the release of CMD releases all other pressed keys in context of it)
800ms: Release CMD

We currently do this by spinning up our own platform keyboard channel.

We're planning on forking the engine to do this for Rive to keep our hack out of our app, but I wanted to bring it up to see if the Flutter team has interest in us attempting to PR this back, or if others are also running into a similar issue perhaps a more general solution could be found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: text inputEntering text in a text field or keyboard related problemscustomer: thriveengineflutter/engine related. See also e: labels.found in release: 2.8Found to occur in 2.8found in release: 2.9Found to occur in 2.9has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions