diff --git a/Cargo.toml b/Cargo.toml index 40a3238..888f987 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +crossterm = "0.27.0" diff --git a/src/main.rs b/src/main.rs index e7a11a9..800105a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,18 @@ +use crossterm::{ + event::{read, Event::Key, KeyCode}, + terminal::{disable_raw_mode, enable_raw_mode}, +}; + fn main() { - println!("Hello, world!"); + let _ = enable_raw_mode(); + loop { + if let Ok(Key(key)) = read() { + if key.code == KeyCode::Char('q') { + break; + } else { + println!("{:?}\r", key); + } + } + } + let _ = disable_raw_mode(); }