Incorrect boolean value returned by keyboard input functions?

This is an issue I’ve been facing for a while but I’ve never really been able to figure it out. It happens for every keyboard input handling library I use, even the one built into GameMaker. Basically the problem is that when a certain key is pressed for an extended period of time, even after letting go of the key the keyboard input function continues to return a boolean value of “true” indicating that the key is still being pressed.

This results in the common bug in games when the player holds on to the arrow keys or any key that controls the character’s movement, and after a while even though the player lets go of the key the character continues to move in that direction.

Is this due to a lag in the input handling? Is it a problem that a third-party user of the library can mitigate? I’d really appreciate an answer to this question that’s been bugging me for a while now. Thanks ;D

Just a stab in the dark here, but my gut says it probably has to do with key repeat and the input buffer filling up. Some libraries have the option to turn it off, or more accurately hide it since it’s controlled by the O/S. Other times you’ll have to make allowances for it in your own code.

If it is present in all the library or apps that you are using, then have you considered other scenarios that it might be possible?

[] Do you have sticky keys or some other driver related bloatware app that does this?
[
] Have you considered checking whether the keyboard is the culprit? Connecting and testing on another system or laptop?
[*] What is the polling rate of GameMaker? As far as I know, GameMaker targets 30 FPS and not 60, and hence it’s input polling rate might also be 30 Hz. So input gathered every 33 ms.

These, are just really guesses. Maybe a test on other system will reveal more clues.

As an example, with libGDX my experience is that polling with Gdx.input.isKey*() is a lot less reliable than event-based handling using InputProcessor. My approach would be to look out for alternate APIs, and if they exist, chose the one closest “to the metal”.

I second SHC suggestions to first rule out both hardware and OS issues before looking for a different API.

I’ve personally come to hate the sticky keys app on windows and its tendency to only pop up when it has the greatest potential to annoy me.

Do you mean the loop returns more than one true even if you click shortly the key?