Qt Auto Repeat Keys, Press and Release

Is there a way to disable keystrokes when they are repeated? I am developing a game, and when I press a key, the players go into operation mode and return to standby mode when the key is released. The problem is that when keyPressEvent () events are repeated, an automatic keyReleaseEvent () event occurs, which leads to the player immediately returning to standby mode after switching to operating mode, thereby revising the step (which I use for the current animation). What should I do to undo this?

+7
c ++ qt 2d-games movement
source share
1 answer

Since you tagged your Qt question, I assume that you are using Qt key events - in this case, use QKeyEvent::isAutoRepeat() to check if the key event is a β€œreal” key event or auto-repeat event.

+13
source share

All Articles