On this page:
get-key-press
ready-key-press
key-value

11 Keyboard 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.

procedure

(get-key-press viewport)  key-press?

  viewport : viewport?
Returns the next key press in the viewport, waiting for a key press if necessary.

procedure

(ready-key-press viewport)  key-press?

  viewport : viewport?
Returns the next key press in the viewport or returns #f if none is available. Unlike get-key-press, ready-key-press always returns immediately.

procedure

(key-value key-press)  (or/c char? symbol?)

  key-press : key-press?
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 get-key-code.