Expand description
§Input
The crossterm_input
crate is deprecated and no longer maintained. The GitHub repository will
be archived soon. All the code is being moved to the crossterm
crate. You can learn more in
the Merge sub-crates to the crossterm crate
issue.
The crossterm_input
crate 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.
Re-exports§
pub use crossterm_screen::IntoRawMode;
pub use crossterm_screen::RawScreen;
pub use crossterm_utils::Result;
Structs§
- Async
Reader - An asynchronous input reader (not blocking).
- Sync
Reader - A synchronous input reader (blocking).
- Terminal
Input - A terminal input.
Enums§
- Input
Event - Represents an input event.
- KeyEvent
- Represents a key or a combination of keys.
- Mouse
Button - Represents a mouse button/wheel.
- Mouse
Event - Represents a mouse event.
Functions§
- input
- Creates a new
TerminalInput
.