If I set up a KeyStateHandler, then using on_key_press seems to make all
the entries in the handler dictionary false. If i delete the on_key_press
function, the handler dictionary works as expected. I tried subclassing
the KeyStateHandler and trying to use it separately as a dictionary
(seperate from the @window.event decorated on_key_press), and I tried
defining my on_key_press in there, and in both cases the presence on an
on_key_press function makes everything in the dictionary false.
If I want to use both ('on key press' and 'is the button still held down'),
do I have to use the on press and on release functions to maintain my own
dictionary? This seems silly.
This is the code I expect to work:
window = pyglet.window.Window(width=width, height=height)
keyboard = key.KeyStateHandler()
window.push_handlers(keyboard)
@window.event
def on_key_press(button, modifiers):
print "pressed:", keyboard[key.UP]
def player_input(dt):
print keyboard[key.UP]
pyglet.clock.schedule(lambda _: None)
pyglet.clock.schedule_interval(player_input,.15)
pyglet.app.run()
No matter what I am holding, there is a steady stream of Falses and
pressing a key prints a false. If I delete the on_key_press function, I
get a steady stream of Trues and Falses as I would expect.
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.