[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Problem with event-handling
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Problem with event-handling
- From: "Kai Kuehne" <kai.kuehne@xxxxxxxxx>
- Date: Wed, 25 Oct 2006 22:34:48 +0200
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Wed, 25 Oct 2006 16:35:33 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=q+vaCA0Uns/BCrlk52GdaY7/qZzeCyL2Xdwre7m9981AgVCcqrato569gLgawWitWwZkQtXim55y/BqTmR6+Q4xXLza0WwAo2ZGq2Dsi7dVI+gQGcDkJnLPDoTXlF1r1iDHxpdKNgvWg1rSEbEStMyxHHhczL1LNt2392sLr1oc=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
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