[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] Handling keys




Hi all,

Does anybody have any good hints for handling keys easily? I need to
handle a lot of various keys and combinations as I need to let the player
type normal text. The text contains upper/lowercase letters, special
character such as ()!#_:;%&/ and so on. Normal lowercase letters, digits
and stuff that can be retrieved without any modifier key is easy to
handle, as I can simply get the name of the key, like this:

	keysym = event.key
	char = pygame.key.name ( keysym )

But, how to handle stuff that requires a modifier key? Uppercase letters
can be handled fairly easily, as they are the normal lowercase key when
KMOD_SHIFT is active. When getting other keys that are not on the same
place on all keyboards I think there will be problems. I don't know where
keyboards such as US keyboards have keys such as !:/()[]{}\ and so on.

So, basically I don't know how to apply all active modifiers to a key in a
portable manner. On my keyboard K_PLUS together with KMOD_SHIFT gives
K_QUESTION. I assume this is not the case on all keyboards. How do I apply
all active modifiers automatically to the key and automatically get the
K_QUESTION from the event? Of course I could assume a sane keyboard
layout, but that is a Scandinavian keyboard in my case, and I think it
will not apply to too many others.

What have I missed here? Or has nobody just not needed to access the full
range of printable characters before?

--------------------+--------------------------------------------------------
Jan 'Chakie' Ekholm |     Balrog New Media    http://www.balrog.fi/
   Linux Inside     | I'm the blue screen of death, nobody hears your screams

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org