OOP Workshop

Keyboard Interaction

def upkeyfunc():
    turtle.penup()
    turtle.forward(15)
    turtle.pendown()

def leftkeyfunc():
    turtle.left(15)

def rightkeyfunc():
    turtle.right(15)

def downkeyfunc():
    turtle.penup()
    turtle.back(15)
    turtle.pendown()

turtle.onkeypress(upkeyfunc, "Up")
turtle.onkeypress(leftkeyfunc, "Left")
turtle.onkeypress(rightkeyfunc, "Right")
turtle.onkeypress(downkeyfunc, "Down")

turtle.listen()