Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HTML/GWT] Input.isKeyPressed Always TRUE If Release Occurs Outside of LibGDX Context #5134

Open
villain-bryan opened this issue Mar 16, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@villain-bryan
Copy link

commented Mar 16, 2018

Issue details

While in a LibGDX environment if you press down a key and then switch to any window outside of LibGDX's scope and release that key, the LibGDX environment does not detect that release event.

Upon re-entry to the LibGDX environment, there should probably be some re-polling evaluation of the keys LibGDX thinks are pressed keys to determine if they are still pressed or not.

It is worth noting that if you press down a key outside of the LibGDX environment and then go into the LibGDX environment, the keyDown is detected. So it appears to be just a bug on re-entry for keys that were pressed upon leaving the context since the release is happening outside of the environment.

Reproduction steps/code

If you ALT+TAB to a window outside of the browser, LibGDX thinks that ALT (and probably the TAB) is still pressed when you return to the LibGDX context. This really can make some keybinds feel sticky and broken.

This also makes for some very weird behavior with TextField (and probably heaps of other components). For the CONTROL_LEFT pressed down case, TextField CONTROL+A and CONTROL+Z offers specialized functionality, so if you press down CONTROL_LEFT, click another window (lose focus on the LibGDX browser), release CONTROL_LEFT, return to LibGDX context, Gdx.input.isKeyPressed(Input.Keys.CONTROL_LEFT) will return true until you just press/release the bugged key in the LibGDX context.

DEMO: https://arenaofkings.com/demo/keydownbug.mp4
Relevant Code: https://hastebin.com/aqubejebuj.cpp

Version of LibGDX and/or relevant dependencies

1.9.8

Please select the affected platforms

  • Android
  • iOS (robovm)
  • iOS (MOE)
  • HTML/GWT
  • Windows
  • Linux
  • MacOS

@villain-bryan villain-bryan changed the title Input.isKeyPressed Always TRUE If Release Occurs Outside of LibGDX Context [HTML5] [HTML/GWT] Input.isKeyPressed Always TRUE If Release Occurs Outside of LibGDX Context Mar 16, 2018

allen-chin added a commit to allen-chin/libgdx that referenced this issue Apr 5, 2018

Fix issue libgdx#5134
Maintains an IntSet of pressed keys to clear when the application or browser loses focus.
@smelc

This comment has been minimized.

Copy link

commented Apr 30, 2018

I'm affected on libgdx 1.9.6. It happens with chrome while it works fine with firefox.

allen-chin added a commit to allen-chin/libgdx that referenced this issue Jun 15, 2018

Fix issue libgdx#5134 now applies to Chrome/Edge/IE
Changed target to window instead of document

Tom-Ski added a commit that referenced this issue Jun 28, 2018

Fix issue #5134 (#5167)
* Fix issue #5134
Maintains an IntSet of pressed keys to clear when the application or browser loses focus.

* Fix issue #5134 now applies to Chrome/Edge/IE
Changed target to window instead of document
@bardiharborow

This comment has been minimized.

Copy link

commented Jan 13, 2019

Fixed by #5167?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.