Crate read_key_termios
source ·Expand description
Read Key (Termios): A tiny crate to read keys on Linux without introducing a huge amount of dependencies.
fn read_key(fd: i32) -> u8; Takes in the FD to read. Blocks until a key has been pressed. This should be used with polling acceptably. It retuns a byte for the user to parse.
fn init(); Enters raw mode, and allows the keys to start being read.
fn close(): Enters cooked mode. Read_key() will not work after this.
Structs§
- The reason we don’t use Bindgen to generate the structures is to keep this crate as small as possible, to suit it’s one purpose. Most users will know what this struct is, if they are familiar with Libc. If, not I suggest you have a look.
Functions§
- Leaves raw mode in your terminal so that the user is returned to a normal terminal instance (cooked mode).
- Enters raw mode in the terminal so that the user can start to read keys properly. This uses bindings to Termios to convert the terminal to raw mode.
- Reads a key from the specified FD and returns it.