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

Created on 16 Mar 2018  路  4Comments  路  Source: libgdx/libgdx

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)
  • [x] HTML/GWT
  • [ ] Windows
  • [ ] Linux
  • [ ] MacOS
bug good first issue gwt input

Most helpful comment

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

All 4 comments

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

Fixed by #5167?

I am affected on libgdx 1.9.6 on Chrome browser

This has been fixed in the linked PR.

Was this page helpful?
0 / 5 - 0 ratings