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

[pygame] pygame.event.key question



Is there a way to go from a pygame.event of type KEYDOWN to the character pressed? I.e. if I have an event e, I can do this:

char = chr(e.key)

but it doesn't take into account caps lock, shift, etc. I can look at the shift state in e.mods, and do this:

char = string.toupper(e.key)

but this still only allows me to get caps. It doesn't let me get '~', '!', etc. Also, since non-English keyboards don't have the same shifted characters in the same position, I can't make a translation table for shift that says { '1' => '!', '2' => '@', ...}.

Has anyone here dealt with this before?

-Matt