-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
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.