Kai -
from pygame import key
def is_pressed(theKey): return key.get_pressed()[theKey]
HTH, Taylor
Hi list! I wanted to create a function which get a key and returns true/false whether the key is currently pressed:
def is_pressed(key): pygame.event.pump() event = pygame.event.poll() if event.type == KEYDOWN: if event.key == key: return True return False
When I use this function: is_pressed(K_SPACE), it doesn't work. The variable "key" always contains 27 (ESC). Can anybody point me to my mistake(s)?
Thanks
Kai