macOS Key Event Slow Repeat

前端 未结 1 1251
有刺的猬
有刺的猬 2021-01-26 13:15

I\'m trying to create a small WASD demo game in macOS. I\'m using NSEvent for handling the key events. To detect the key presses, I\'m searching for keyDown

1条回答
  •  无人及你
    2021-01-26 13:17

    You should ignore key-repeat events (with isARepeat true). Instead, when you get a key-down event, start a timer that fires however often you want to advance your game state. Advance the game state in that timer's firing code. When you get a key-up event, stop the timer.

    0 讨论(0)
提交回复
热议问题