Handling keyboard events correctly in games

❯ xset q
Keyboard Control:
  auto repeat:  on    ...
  ...
  auto repeat delay:  250    repeat rate:  30

This is my keyboard repeat rate. Because it is too fast, many games can’t work correctly with this.

What worked well

  • GTK
  • Qt
  • Firefox and web games
  • GLFW3 (including raylib)

What worked poorly

  • Godot games
  • Unity games
  • Unity games on Wine

I suspect it is because 1 of 2 reasons.

  1. Key repeat is recognized as noraml key press. In XInput, the repeat flag of a XIEvent would be set. Ignore those.
  2. Keyboard state is not calculated correctly.

If possible, I recommending using a game engine that let’s you handle input events as events, not “current state”.