gsh/input/reader

The reader module provides the non-blocking event loop for terminal input.

When the terminal is in raw mode, keystrokes are streamed immediately without waiting for the user to press Enter. This module uses the etch library to poll the terminal, filter out noise (like mouse clicks or window resizes), and map valid keystrokes into the shell’s internal Key domain model.

Values

pub fn read_key() -> key.Key

Polls the terminal for a keyboard event.

Because input.read() is non-blocking, calling it in a tight loop would consume 100% of a CPU core. To prevent this, if no key is pressed (None), the process sleeps for 5 milliseconds before polling again. Non-keyboard events (like mouse movements) are safely ignored.

Search Document