Function rdev::listen [−][src]
pub fn listen<T>(callback: T) -> Result<(), ListenError> where
T: FnMut(Event) + 'static,
Listening to global events. Caveat: On MacOS, you require the listen loop needs to be the primary app (no fork before) and need to have accessibility settings enabled.
use rdev::{listen, Event}; fn callback(event: Event) { println!("My callback {:?}", event); match event.name{ Some(string) => println!("User wrote {:?}", string), None => () } } fn main(){ // This will block. if let Err(error) = listen(callback) { println!("Error: {:?}", error) } }