The mod flag comes in on the "mod" attribute of the event, it isn't part of
the key.
so like this:
alt_f4 = (event.key == K_F4 and event.mod == KMOD_ALT)
there is a list of events and their attributes here:
http://www.pygame.org/docs/ref/event.html
On Sun, Sep 13, 2009 at 10:34 AM, Fawkes <[email protected]> wrote:
> Hello,
>
> I am having trouble with getting Pygame to recognize ALT+F4. I'm using
> this combination of keys to invoke an exit from the program.
>
> The code I am using works as follows:
>
> for event in pygame.event.get():
> if event.type == QUIT or (event.type == KEYDOWN and
> event.key == KMOD_ALT|K_F4):
> exit()
> # Other event commands follow
>
> Every other event is recognized on this computer and exiting with ALT
> +F4 seems to work on several other computers but I do not know why it
> does not work with this one. It neither recognizes Left Alt + F4 nor
> Right Alt + F4. What would be the best way to diagnose the cause of
> this problem? I would greatly appreciate any help you may be able to
> give me.
>
> I am running Windows Vista SP1 - 64 Bit.
>
> Thank you in advance
> -Fawkes
>