Skip to content

Conversation

ArturKrys
Copy link

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

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.
@ArturKrys ArturKrys requested a review from 4ian as a code owner August 1, 2025 01:59
@ArturKrys
Copy link
Author

Hi @4ian — Travis CI is failing with a CXXABI_1.3.11 not found error.
It seems related to clang (v18.1.8) being used with a downgraded libstdc++6 (v5.4.0), which breaks compiler compatibility.

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!

@4ian
Copy link
Owner

4ian commented Aug 3, 2025

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"?
For example, in this branch we added a "releaseAllPressedKeys":

/**
* Release all keys that are currently pressed.
* Note: if you want to discard pressed keys without considering them as
* released, check `clearAllPressedKeys` instead.
*/
releaseAllPressedKeys(): void {
for (const locationAwareKeyCode in this._pressedKeys.items) {
this._pressedKeys.put(locationAwareKeyCode, false);
this._releasedKeys.put(locationAwareKeyCode, true);
}
}

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?

@4ian 4ian force-pushed the master branch 3 times, most recently from 8a32fc5 to 846afd9 Compare August 30, 2025 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants