April 2024
Beginner to intermediate
500 pages
24h 20m
English
The turtle module provides three methods to register callbacks for key, mouse, and timer events:
onkey
onclick
ontimer
In addition, the listen method is used to give the turtle canvas focus so that the event handler can respond to key presses. Each method has conventions for the parameters it accepts. Table 13.3 explains each of these methods to register callbacks for events, as well as the listen method.
Table 13.3 Turtle Methods to Register Callbacks
| Method | Description |
|---|---|
| onkey(function, key) | Binds a function to a key press so that function is called when a specified key is pressed. The function must take no parameters. key is a string representing a key on the keyboard. The keyboard must ... |
Read now
Unlock full access