question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gdx.input.isKeyPressed(ANY_KEY) broken (Linux)

See original GitHub issue

After dragging the application window, the Gdx.input.isKeyPressed() method always returns false when Input.Keys.ANY_KEY is passed as parameter.

Issue details

I’m not familiar with the libgdx codebase enough, but I think the pressedKeys value stops being updated at a certain point for whatever reason. This is also a platform specfic issue. I tested the same program on Windows 7 and it works as expected.

Reproduction steps/code

SSCCE That demostrates the issue..

  1. Clone the repository linked above.
  2. Run the desktop launcher.
  3. Press left, right, up, down, and space keys to verify that the image moves.
  4. Drag the window either with your mouse or a key combination.
  5. Repeat step 3.

Expected behaviour: At step 5 the program behaves like in step 3 with key presses moving the image inside the application window.

Observed behaviour: At step 5, the program keeps running normally, but Gdx.input.isKeyPressed(Input.Keys.ANY_KEY) always returns false even though input is still correctly processed.

Version of LibGDX and/or relevant dependencies

libgdx 1.9.8

Environment

OS: Linux Kernel: x86_64 Linux 4.14.15-1-ARCH WM: i3wm CPU: Intel Core i7-5600U @ 4x 3.2GHz GPU: Mesa DRI Intel® HD Graphics 5500 (Broadwell GT2)

Java implementation

openjdk version “1.8.0_162” OpenJDK Runtime Environment (build 1.8.0_162-b12) OpenJDK 64-Bit Server VM (build 25.162-b12, mixed mode)

Affected platforms

  • Android
  • iOS (robovm)
  • iOS (MOE)
  • HTML/GWT
  • Windows
  • Linux
  • MacOS
[EDIT]
  • Added java implementation information (15 April 2018)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
crykncommented, Nov 20, 2020

I think we can close this issue if the bug doesn’t happen with LWJGL 3. LWJGL 2 itself is no longer actively developed since 4 years ago, so legacy projects should consider migrating over to our LWJGL 3 backend anyway.

1reaction
yuripourrecommented, Apr 6, 2018

@nhatzHK thank you for your information about JVM version.

I may be wrong but my guess is that the (awt) window is losing focus after move event, and messing with input listeners, I have to take a deeper look to understand what is happening.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] Gdx.input.isKey(Just)Pressed(Keys.BACKSLASH ...
isKeyPressed (Keys.BACKSLASH) wont work on Linux Mint 18 KDE Edition, on windows it works fine, but on Linux it doesn't give any output....
Read more >
LibGDX - isKeyPressed() do not count just one - Stack Overflow
Try this: if (Gdx.input.isKeyJustPressed(Keys.A)) { System.out.println("KEY PRESSED"); }. It only runs once when you press the key, ...
Read more >
libGDX: Why doesn't Gdx.input.isKeyJustPressed() work?
I'm going to use the isKeyPressed() method and prevent multiple calls by saving the last key state and make only a call when...
Read more >
CS 328 Introduction to Computer Game Development
Pixmap is easily writable; texture is almost write-once, read-only. Polling vs. Event-driven input. Code like if (Gdx.input.isKeyPressed(Keys.A)) ... is ...
Read more >
com.badlogic.gdx.Input.isKeyPressed java code examples
@Override public void update () { // If the left or right key is pressed, rotate the character and update its physics update...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found