[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Problem with event-handling



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