[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] key press question
On Tue, Dec 11, 2001 at 07:20:31PM -0800, Robert Flemming wrote:
> Okay this was MUCH easier than I thought.
If I got your idea right it can be even easier
> 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
[..]
Another solution would simply be:
while 1:
event = pygame.event.wait()
if event.type == KEYDOWN:
if pygame.key.get_mods() & KMOD_LALT: print "meta down"
else: print "just down"
I don't know about the interals of pygame very well.. maybe Pete can
lighten it up a little.. how does key.get_mods work? Is there any
processing necessary? Then it would be faster to save a flag like Robert
did. But iirc the state of the mod-keys gets updated anyways and so
the get_mods just returns a ready-to-go value ?
--
Raiser, Frank aka CrashChaos
IRC: irc.openprojects.net #pygame
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org