turtle.listen() turtle.onkey(def, 'key')

Read more of this post