[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] pygame.event.key question
Matt Campbell wrote:
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:
Has anyone here dealt with this before?
yes, and yes. the KEYDOWN type events come with an attribute named
"unicode". this is the fully translated character of the key pressed.
This will usually be a single character unicode string of the keyboard
letter pressed. although it will also be an empty unicode string for
keys with no representation (control, etc)
it works really well, and since the pygame font Render works fairly well
with unicode it's not hard to render these characters to the screen.