You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The KeyboardListener and Focus.onKeyEvent that replace RawKeyboardListener and Focus.onKey have a bug in triggering the KeyUpEvent correctly in the JS and WASM builds. The KeyUpEvent is not triggered when a key is released when pressing multiple keys in sequence and releasing them in reverse order. This bug is not present in VM builds.
A reproduction issue sample app is provided in the code sample section.
This issue reproduces on all current Flutter channels.
Background
We discovered this bug after starting to more actively pushing and using WEB builds of the game platform HypeHype.
We had already migrated from the deprecated RawKeyboardListener to the new KeyboardListener and its related APIs, but due to this issue we had to revert the migration and continue to use the deprecated RawKeyboardListener and its related APIs.
When making games, having correct n-key rollover function and n-key release sequence is critical, as game-play typically depends on being able to press multiple keys at the same time and having the game react correctly to their triggered key down and key up release order.
Request to hold removal of deprecated RawKeyboardListener and related APIs until issue is fixed
We kindly ask if you can hold the removal of the deprecated RawKeyboardListener and its related APIs, until this issue is resolved and its fix has landed in the Flutter stable channel.
The RawKeyboardListener and its related APIs are scheduled for removal here #136419 by @gspencergoog.
Expected results
When pressing multiple keys in sequence and releasing them in reverse order, the KeyUpEvent should be triggered for each key in the correct release order.
Using the reproduction keyboard event listener demo app, we can see that in a VM build the KeyUpEvent is triggered correctly for each key in the correct order.
Using the VM build with RawKeyboardListener or Focus.onKey APIs
Press and hold [1] then, press and hold [2] then press and hold [3].
Release [3], keep holding [2] and [1].
Release [2], keep holding [1], the RawKeyUpEvent for [2] is triggered.
Release [1], the RawKeyUpEvent for [1] is triggered.
This is correct and expected behavior.
Using the VM build with KeyboardListener or Focus.onKeyEvent APIs
Press and hold [1] then, press and hold 2 then press and hold [3].
Release [3], keep holding [2] and [1].
Release [2], keep holding [1], the KeyUpEvent for [2] is triggered.
Release [1], the KeyUpEvent for [1] is triggered.
This is correct and expected behavior.
This is demonstrated in the video recording below:
Issue.keyboard.ok.mp4
Actual results
When pressing multiple keys in sequence and releasing them in reverse order, the KeyUpEvent is not triggered for each key in the correct order on WEB builds. The same incorrect result is present in both JS and WASM builds. The previous key that were pressed are triggered automatically when last key is released, slightly after it, or not at all.
Using WEB build with RawKeyboardListener or Focus.onKey APIs
Press and hold [1] then, press and hold [2] then press and hold [3].
Release [3], keep holding [2] and [1].
Release [2], keep holding [1], the RawKeyUpEvent for [2] is triggered.
Release [1], the RawKeyUpEvent for [1] is triggered.
This is correct and expected behavior.
Using the WEB build with KeyboardListener or Focus.onKeyEvent APIs
Press and hold [1] then, press and hold [2] then press and hold [3].
Release [3], keep holding [2] and [1], the KeyUpEvent for [2] is triggered shortly after, despite [2] still being pressed.
Release [2], keep holding [1], the actual KeyUpEvent for [2] is not triggered.
Release [1], the KeyUpEvent for [1] is not triggered.
This is incorrect and not expected behavior when using the KeyboardListener and related APIs on WEB builds.
This is demonstrated in the video recording below, the incorrect behavior is shown in the right column:
Issue.keyboard.FAIL.mp4
The recording shows a Web WASM build, the result is the same in a Web JS build.
Steps to reproduce
The
KeyboardListenerandFocus.onKeyEventthat replaceRawKeyboardListenerandFocus.onKeyhave a bug in triggering theKeyUpEventcorrectly in the JS and WASM builds. TheKeyUpEventis not triggered when a key is released when pressing multiple keys in sequence and releasing them in reverse order. This bug is not present in VM builds.A reproduction issue sample app is provided in the code sample section.
This issue reproduces on all current Flutter channels.
Background
We discovered this bug after starting to more actively pushing and using WEB builds of the game platform HypeHype.
We had already migrated from the deprecated
RawKeyboardListenerto the newKeyboardListenerand its related APIs, but due to this issue we had to revert the migration and continue to use the deprecatedRawKeyboardListenerand its related APIs.When making games, having correct n-key rollover function and n-key release sequence is critical, as game-play typically depends on being able to press multiple keys at the same time and having the game react correctly to their triggered key down and key up release order.
Request to hold removal of deprecated
RawKeyboardListenerand related APIs until issue is fixedWe kindly ask if you can hold the removal of the deprecated
RawKeyboardListenerand its related APIs, until this issue is resolved and its fix has landed in the Flutter stable channel.The
RawKeyboardListenerand its related APIs are scheduled for removal here #136419 by @gspencergoog.Expected results
When pressing multiple keys in sequence and releasing them in reverse order, the
KeyUpEventshould be triggered for each key in the correct release order.Using the reproduction keyboard event listener demo app, we can see that in a VM build the
KeyUpEventis triggered correctly for each key in the correct order.Using the VM build with
RawKeyboardListenerorFocus.onKeyAPIs[1]then, press and hold[2]then press and hold[3].[3], keep holding[2]and[1].[2], keep holding[1], theRawKeyUpEventfor[2]is triggered.[1], theRawKeyUpEventfor[1]is triggered.This is correct and expected behavior.
Using the VM build with
KeyboardListenerorFocus.onKeyEventAPIs[1]then, press and hold2then press and hold[3].[3], keep holding[2]and[1].[2], keep holding[1], theKeyUpEventfor[2]is triggered.[1], theKeyUpEventfor[1]is triggered.This is correct and expected behavior.
This is demonstrated in the video recording below:
Issue.keyboard.ok.mp4
Actual results
When pressing multiple keys in sequence and releasing them in reverse order, the
KeyUpEventis not triggered for each key in the correct order on WEB builds. The same incorrect result is present in both JS and WASM builds. The previous key that were pressed are triggered automatically when last key is released, slightly after it, or not at all.Using WEB build with
RawKeyboardListenerorFocus.onKeyAPIs[1]then, press and hold[2]then press and hold[3].[3], keep holding[2]and[1].[2], keep holding[1], theRawKeyUpEventfor[2]is triggered.[1], theRawKeyUpEventfor[1]is triggered.This is correct and expected behavior.
Using the WEB build with
KeyboardListenerorFocus.onKeyEventAPIs[1]then, press and hold[2]then press and hold[3].[3], keep holding[2]and[1], theKeyUpEventfor[2]is triggered shortly after, despite[2]still being pressed.[2], keep holding[1], the actualKeyUpEventfor[2]is not triggered.[1], theKeyUpEventfor[1]is not triggered.This is incorrect and not expected behavior when using the
KeyboardListenerand related APIs on WEB builds.This is demonstrated in the video recording below, the incorrect behavior is shown in the right column:
Issue.keyboard.FAIL.mp4
The recording shows a Web WASM build, the result is the same in a Web JS build.
Code sample
Code sample
Flutter version
This issue reproduces on all current Flutter channels, the latest tested master version is
3.29.0-1.0.pre.127.Flutter Doctor output
Doctor output