python w/ turtle onkey
how to I put onkey for python w/ turtle for pen up and down
here's an example on how you can use
import turtle window = turtle.Screen() window.bgcolor('black') window.tracer(10) t = turtle.Turtle() t.color("red") t.shape('classic') def left(): t.left(90) def right(): t.right(90) def up(): t.forward(100) def down(): t.backward(100) window.listen() window.onkey(left, 'Left') window.onkey(right, 'Right') window.onkey(up, 'Up') window.onkey(down, 'Down')
the above code allows you to move up, down, left, or right. The functions make it go in directions, and the onkey allows specific keys to perform the task.
It should work