[Tutor] Keyboard Module

Ryan Strunk ryan.strunk at gmail.com
Wed Oct 12 03:32:52 CEST 2011


Hello everyone,
I'm still hard at work on this boxing game; I know, I think it's taking
forever too. I've recently run into some trouble with my current keyboard
handler, and I'm hoping someone here might have a recommendation as to what
I could use to handle keyboard input for this and future projects.
The keyboard module I currently have access to is a wrapper for the wx
keyboard handler, which is fine, but it prevents me from holding one key and
pressing another. In an ideal world, I'd love something like this:

def left_hand(self):
	if key_down('up'):
		self.left_head_hook()
	elif key_down('down'):
		self.left_uppercut()
	elif key_down('left'):
		self.left_body_hook()
	else:
		self.jab()

The above functionality could be useful in other places as well. I would
like to some day create a keyboard trainer for my students, giving them the
ability to practice key combinations like capslock+t, control+alt+pgdn,
numpad0+numpad4, and so on.
I thought of using Pygame to pull this off, but I gather from my research
that I can't just use certain pieces of Pygame; in order to get the
functionality I want out of the keyboard module, I'll need other modules as
well. I don't want to work specifically in Pygame, because I've heard Pygame
is quite bloated and requires a good deal of overhead. (I wouldn't mind
being proven wrong on this)
All of which leads me to my question. Can anyone recommend a keyboard module
which will allow me to work with various facets of the keyboard to execute
functions. I would love to have access to presses, holds, and releases, and
it would be helpful to use unorthodox combinations of keys.
Thanks for any recommendations or advice you all have.
Best,
Ryan



More information about the Tutor mailing list