Fix #7429: Prevent stuck keys when game window loses focus#7753
Fix #7429: Prevent stuck keys when game window loses focus#7753ArturKrys wants to merge 1 commit into4ian:masterfrom
Conversation
Fixes an issue where keys remain stuck if held while the game window loses focus. Adds a blur event listener to clear pressed key states using the input manager.
|
Hi @4ian — Travis CI is failing with a CXXABI_1.3.11 not found error. My PR only touches a JS file (runtimegame-pixi-renderer.ts), so the build failure seems to be caused by CI config, not the code but I'm not entirely sure. Could you take a look or advise on next steps? Thanks! |
|
Hi! Thanks for the PR. You can safely ignore Travis CI errors - the CI is out of date and we'll probably remove/replace it. For the changes, do you think we should consider these keys as "discarded" (like you did) or simulate that they are "released"? GDevelop/GDJS/Runtime/inputmanager.ts Lines 151 to 161 in 726d3a8 From the point of view of the game creator, I'm not sure if we should discard the keys (meaning a key could be pressed, but then never released, and then pressed again, from the point of view of the game) or simulate they are released (so we would keep the invariant that "one key press will be followed, at some point, by a key release" - but this would be simulated so it's also not entirely true). What do you think? |
8a32fc5 to
846afd9
Compare
Summary
Fixes a bug where keyboard inputs could become stuck when the user unfocus the window.
Changes
Ensures keys pressed are properly handled when the editor loses focus.
Cleans up event listeners to avoid lingering state when switching scenes.
Motivation
The issue led to confusing and frustrating user experience when keys (like arrow keys or shortcuts) would appear stuck after interacting with other windows or tabs. This fix restores reliable keyboard behavior.
Demo
untitled.mp4