0

I am working with PyGame for the first time, and I haven't been able to find any way to handle event in a non-blocking way. For instance if I am playing a game with a character moving according to key pressing, I want the character to move continuously if I maintain the key pressed, and not having to release the key each time.

I am starting to think it is not possible with PyGame, am I right ?

Thanks.

Adrien
  • 3
  • 2
  • I guess almost every tutorial out there explains how to do this. [Here's an answer](http://stackoverflow.com/a/33539340/6220679) that shows you how to achieve this with an event loop, but you can also search for `pygame.key.get_pressed`. If you don't know yet how dictionaries work, I can show you a simpler solution than Sloth's. – skrx May 13 '17 at 18:49
  • Take a look at the new [answer](http://stackoverflow.com/a/43957063/6220679). – skrx May 13 '17 at 19:15

1 Answers1

1

Maybe you can use pygame.key.set_repeat() which sends multiple keydown events when you hold down a key; From here: https://www.pygame.org/docs/ref/key.html

DaOnlyOwner
  • 343
  • 3
  • 8