3

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?

ggorlen
  • 44,755
  • 7
  • 76
  • 106
  • For this to work, you'd need a press and a release method. I don't find a release (for keys!) in the documentation, so I presume it doesn't work. – deets Oct 25 '14 at 17:56
  • @deets Thank you for the idea. I'll search something like that now. If there's a way, it should work.. – David Jandrey Oct 26 '14 at 12:02
  • There's onkeyrelease. I think I can do something with that. Thank you. – David Jandrey Oct 26 '14 at 12:04
  • Does this answer your question? [How to bind several key presses together in turtle graphics?](https://stackoverflow.com/questions/47879608/how-to-bind-several-key-presses-together-in-turtle-graphics) – ggorlen Feb 03 '22 at 22:47

0 Answers0