detecting two simultaneous keys in pyglet (python)
Question
I wanted to know how to detect when two keys are simultaneously pressed using pyglet. I currently have
def on_text_motion(self, motion): (dx,dy) = ARROW_KEY_TO_VERSOR[motion] self.window.move_dx_dy((dx,dy))
But this only gets arrow keys one at a time... I'd like to distinguish between the combination UP+LEFT and UP, then LEFT...
Hope I made myself clear Manu
Solution
Try pyglet.window.key.KeyStateHandler:
import pyglet
key = pyglet.window.key
win = pyglet.window.Window()
keyboard = key.KeyStateHandler()
win.push_handlers(keyboard)
print keyboard[key.UP] and keyboard[key.LEFT]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow