[][src]Crate crossterm_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.


pub use crossterm_screen::IntoRawMode;
pub use crossterm_screen::RawScreen;
pub use crossterm_utils::Result;



An asynchronous input reader (not blocking).


A synchronous input reader (blocking).


A terminal input.



Represents an input event.


Represents a key or a combination of keys.


Represents a mouse button/wheel.


Represents a mouse event.



Creates a new TerminalInput.