- Pyroom
- Tutorials
- Python Turtle
- Control a turtle with the keyboard
Control a turtle with the keyboard
Events turn a drawing into a game. onkey connects a key to a function, and listen starts waiting for presses.
Advanced Video coming soon. The steps below show everything the video will cover.
Steps
- Write one small function for each move.
- onkey connects each arrow key to a function. listen starts waiting for presses.
- Run it, then click the drawing so it receives the keys.
- Now drive the turtle with the arrow keys.
Read the transcript
Write one small function for each move.
onkey connects each arrow key to a function. listen starts waiting for presses.
Run it, then click the drawing so it receives the keys.
Now drive the turtle with the arrow keys.
More Python Turtle tutorials
- Draw a square with Python turtle · Beginner
- Draw spirals with loops in Python turtle · Intermediate