[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] key press question
Okay this was MUCH easier than I thought. All I was really trying to create
was a shift or meta key so once I thought about it, it was very simple. In my
main loop I use the event queue and the first tests I do are for KEYDOWN and
KEYUP along with my metakey and set a flag accordingly. From then on all
further KEYDOWN tests also test to see if the metakey flag is set. Perhaps my
initial question made it sound like I was trying to do a whole lot more. Here
is stripped down example:
metakey = 0
while 1:
event = pygame.event.wait()
if event.type == KEYDOWN and event.key == K_LALT:
metakey = 1
elif event.type == KEYUP and event.key == K_LALT:
metakey = 0
elif event.type == KEYDOWN and event.key == K_DOWN and metakey:
print "Meta Down"
elif event.type == KEYDOWN and event.key == K_DOWN and not metakey:
print "Down"
Of course after the fact it seems like a stupid question. Thanks for your
help. I'd expect a few more lame questions from me in the future. :)
Robert
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org