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

Closed
1 of 7 tasks
villain-bryan opened this issue Mar 16, 2018 · 4 comments
Closed
1 of 7 tasks
Labels

Comments

@villain-bryan
Copy link

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
@smelc
Copy link

smelc commented Apr 30, 2018

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

Tom-Ski pushed a commit that referenced this issue Jun 28, 2018
* 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
Copy link

Fixed by #5167?

@Sholanki
Copy link

Sholanki commented Apr 5, 2020

I am affected on libgdx 1.9.6 on Chrome browser

@MrStahlfelge MrStahlfelge added the input Concerning Gdx.input label Aug 30, 2020
@MrStahlfelge
Copy link
Member

This has been fixed in the linked PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants
@smelc @bardiharborow @villain-bryan @Tom-Ski @MrStahlfelge @Sholanki and others