Hello Guest

[BUG] LWJGL does not register a key-down event if that key is 'already' down

  • 1 Replies
  • 3201 Views
*

Offline TLH

  • *
  • 6
Specifically, if LWJGL 'thinks' that key is already down. This behaviour differs from AWT KeyListener, which allows keys to be pressed multiple times without release.

There's a couple of ways I've observed this:
  • Using a keyboard with additional buttons (such as media buttons), these all register as key 0 (or KEY_NONE, I believe), which could give two downs followed by two ups.
  • Using a keyboard with macro buttons (such as a Logitech G510) set to emulate special characters, its keypresses come without a key-up event at all.

In the latter case, an LWJGL key-down event is generated for one single keypress, and Keyboard.getEventCharacter does contain the simulated character.

Obviously the buck is not entirely with LWJGL, far from it, however it is still the case that the event stream derived from an AWT KeyListener does report multiple key-downs without key-ups. I have made several attempts to use that alongside LWJGL, including:
  • Creating a dummy Component and attaching a KeyListener; I can't find a way to let it take and retain keyboard focus.
  • Using FocusListeners to trace the means by which LWJGL has keyboard focus in the hope of attaching a KeyListener directly to that. I found that the AWT Canvas gets focus briefly, then focus disappears to a mystery target (JNI?) which only shows up as null.

If I'm missing something, such as if LWJGL is functioning as intended but there does exist a way to do custom handling of input events, that works too :)

Perhaps
Code: [Select]
Keyboard.enableRepeatEvents(true);?