forked from chiehw/rdev
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb9a29e
commit e43c6a2
Showing
4 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use rdev::{listen, Event, EventType}; | ||
|
||
fn callback(event: Event) { | ||
match event.event_type { | ||
EventType::KeyPress(_key) | EventType::KeyRelease(_key) => { | ||
println!("User wrote {:?}", event.unicode); | ||
} | ||
_ => (), | ||
} | ||
} | ||
|
||
fn main() { | ||
// This will block. | ||
use std::thread; | ||
use std::time::Duration; | ||
let handle = thread::spawn(|| { | ||
if let Err(error) = listen(callback) { | ||
println!("Error: {:?}", error) | ||
} | ||
}); | ||
thread::sleep(Duration::from_secs(5)); | ||
rdev::stop_listen().unwrap(); | ||
let _ = handle.join(); | ||
println!("Done"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters