[−][src]Module crossterm::input
A module to read the input events.
Input
The input
module provides a functionality to read the input events.
This documentation does not contain a lot of examples. The reason is that it's fairly obvious how to use this crate. Although, we do provide examples repository to demonstrate the capabilities.
Synchronous vs Asynchronous
Synchronous Reading
Read the input synchronously from the user, the reads performed will be blocking calls. Using synchronous over asynchronous reading has the benefit that it is using fewer resources than the asynchronous because background thread and queues are left away.
See the SyncReader
documentation for more details.
Asynchronous Reading
Read the input asynchronously, input events are gathered in the background and queued for you to read. Using asynchronous reading has the benefit that input events are queued until you read them. You can poll for occurred events, and the reads won't block your program.
See the AsyncReader
documentation for more details.
Technical details
On UNIX systems crossterm reads from the TTY, on Windows, it uses ReadConsoleInputW
.
For asynchronous reading, a background thread will be fired up to read input events,
occurred events will be queued on an MPSC-channel, and the user can iterate over those events.
The terminal has to be in the raw mode, raw mode prevents the input of the user to be displayed
on the terminal screen. See the
crossterm_screen
crate documentation to learn more.
Structs
AsyncReader | An asynchronous input reader (not blocking). |
DisableMouseCapture | A command that disables mouse event monitoring. |
EnableMouseCapture | A command that enables mouse mode |
SyncReader | A synchronous input reader (blocking). |
TerminalInput | A terminal input. |
Enums
InputEvent | Represents an input event. |
KeyEvent | Represents a key or a combination of keys. |
MouseButton | Represents a mouse button/wheel. |
MouseEvent | Represents a mouse event. |
Functions
input | Creates a new |