'Handle multiple keypresses at once in Turtle
I've got a (hopefully) simple question. I want to script something, that lets two users move their python turtles with keypresses. My script part:
#Forward
onkeypress(lambda:turtle1.forward(1),"Up")
onkeypress(lambda:turtle2.forward(1),"w")
#Backward
onkeypress(lambda:turtle1.forward(-1),"Down")
onkeypress(lambda:turtle2.forward(-1),"s")
listen()
If I do this, one turtle stops moving, when the other one starts. So "listen" does only listen for one keypress at once.
What to do if I want to handle two key inputs at once?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
