![[index]](../icons/index.gif)
Next: Turtles
Up: Viewport Graphics
Previous: Mouse Operations
The graphics library contains functions that report key presses from
the keyboard. The functions get-key-press and
ready-key-press return a ``key-press descriptor,'' and then
key-value takes the descriptor and returns a character or
symbol (usually a character) representing the key that was pressed.
Key presses are buffered and returned in the same order in which they
occurred. Thus, the descriptors returned by get-key-press and
ready-key-press may be from presses that occurred long before
these functions were called.
-
(get-key-press viewport)
Takes a viewport descriptor and returns
a key press descriptor.
It returns the next key press in the viewport, waiting for a click
if necessary.
-
(ready-key-press viewport)
Takes a viewport descriptor and returns
either a key press descriptor, or else #f if none is available.
Unlike the previous function, ready-key-press returns immediately.
-
(key-value key-press)
Takes a key press descriptor and returns a character or special
symbol for the key that was pressed. For example, the Enter key
generates #\return, and the up-arrow key generates 'up.
For a complete list of possible return values, see PLT MrEd: Graphical Toolbox Manual.
-
(viewport-flush-input viewport)
As noted above, key presses are buffered.
viewport-flush-input takes a viewport descriptor
and empties the input buffer of mouse and keyboard events.
This action is useful in some real-time applications.
PLT