[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] pygame.event.key question
- To: pygame-users@seul.org
- Subject: [pygame] pygame.event.key question
- From: Matt Campbell <ghwerig@cox.net>
- Date: Thu, 08 May 2003 16:10:53 -0700
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Thu, 08 May 2003 19:00:58 -0400
- Reply-to: pygame-users@seul.org
- Sender: owner-pygame-users@seul.org
- User-agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.3) Gecko/20030312
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