Crates.io | rawkey |
lib.rs | rawkey |
version | 0.1.3 |
source | src |
created_at | 2019-07-16 18:29:05.366839 |
updated_at | 2020-09-14 20:57:06.158341 |
description | Raw terminal key input |
homepage | https://github.com/jonathandturner/rawkey |
repository | https://github.com/jonathandturner/rawkey |
max_upload_size | |
id | 149446 |
size | 13,182 |
Early release of a project to support raw key input in terminals. Currently, this supports the following raw keys across the major OSes:
Rather than using events, rawkey offers a way to scan to see if the key is pressed or not.
use rawkey::{KeyCode, RawKey};
let mut rawkey = RawKey::new();
loop {
if rawkey.is_pressed(KeyCode::Escape) {
break;
}
if rawkey.is_pressed(KeyCode::UpArrow) {
print!("Up ");
}
if rawkey.is_pressed(KeyCode::DownArrow) {
print!("Down ");
}
if rawkey.is_pressed(KeyCode::LeftArrow) {
print!("Left ");
}
if rawkey.is_pressed(KeyCode::RightArrow) {
print!("Right ");
}
println!("");
}