Skip to content

Commit

Permalink
events added
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacperacy committed Mar 2, 2024
1 parent 29dd1e6 commit 9d6ab77
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
17 changes: 16 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 9d6ab77

Please sign in to comment.