On Tue, Apr 19, 2011 at 11:12 PM, Eric Poulsen <[email protected]>wrote:
> I'm toying around with game code; basic space ship shooter. I've
> assigned these keys for controls:
>
> UP: Thrust
> LEFT: Rotate ship counter-clockwise
> RIGHT: Rotate ship clockwise
> SPACE: Fire laser
>
> Problem is that you can't press certain key combinations (i.e. keys
> held down simultaneously):
>
> (in this order)
> Press and hold LEFT
> Press and hold UP
> Press and hold SPACE
>
> I would expect Pyglet to send three on_key_press events, one for each
> key press. If I change the above to be keys to be RIGHT, UP, SPACE,
> it works as expected.
>
> I've attached sample code that re-creates the problem:
>
> -- BEGIN CODE --
> #!/usr/bin/python
>
> import pyglet
> from pyglet.window import key
> import sys
>
> window = pyglet.window.Window()
>
> @window.event
> def on_key_press(symbol, modifiers):
>
> sys.stdout.write('Key:')
> if symbol == key.UP:
> sys.stdout.write('UP')
> elif symbol == key.LEFT:
> sys.stdout.write('LEFT')
> elif symbol == key.RIGHT:
> sys.stdout.write('RIGHT')
> elif symbol == key.SPACE:
> sys.stdout.write('SPACE')
> else:
> sys.stdout.write('?')
>
> sys.stdout.write('\n')
>
> @window.event
> def on_draw():
> window.clear()
>
> pyglet.app.run()
>
> -- END CODE --
>
>
> Anyone have any ideas?
Sadly, that is not a limitation of pyglet. It is a phenomenon known as
jamming, and is a limitation of the way normal keyboards detect keypresses.
For a brief overview, see the wikipedia page:
http://en.wikipedia.org/wiki/Rollover_(key)#Key_jamming_and_ghosting
--
Tristam MacDonald
http://swiftcoder.wordpress.com/
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.