My pgzero key press event handler does recognize a pressed key only once (until released) but does not support repeated key press events if the key is kept pressed.
How can I achieve this?
PS: Since pgzero
is implemented using pygame
perhaps a pygame
solution could work...
import pgzrun
counter = 1
def on_key_down(key):
global counter
if key == keys.SPACE:
print("Space key pressed...")
counter = counter + 1
def draw():
screen.clear()
screen.draw.text("Space key pressed counter: " + str(counter), (10, 10))
pgzrun.go()