Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable key pressing events when they repeat

Is there any way to disable key pressing events when they are repeating?

I'm developing a game and when I press a key, the players goes into running mode and goes back to standing mode when the key is released. The problem is that with repeating keyPressEvent() events, there are automatically keyReleaseEvent() events, making the player immediately going back to standing mode after going into running mode, thus resetting the step (that I use for the running animation).

What should I do to cancel this?

like image 955
Kanghu Avatar asked Apr 16 '14 16:04

Kanghu


1 Answers

Since you tagged your question with Qt, I assume your are using Qt key events - in that case, use QKeyEvent::isAutoRepeat() to check if the key event is a "real" key event or an autorepeat event.

like image 141
Thomas McGuire Avatar answered Oct 03 '22 08:10

Thomas McGuire