This Article IsCreated at don't-know-whenLast Modified at 2023-04-22Referenced as ia.www.b07

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

What worked poorly

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”.