Created
October 14, 2021 06:59
-
-
Save Japanuspus/d3ef776fa451382ece8a24315b38afd5 to your computer and use it in GitHub Desktop.
Cross-platform global hotkey in Rust
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
use tauri_hotkey as hotkey; // Discontinued, but v0.1.2 is working fine as of 2021-10-14 | |
use std::io::{stdin, Read}; | |
fn main() { | |
let spec = "ctrl+alt+r"; | |
let mut hk = hotkey::HotkeyManager::new(); | |
let key = hotkey::parse_hotkey(&spec).unwrap(); | |
println!("Listening for {}. Enter to exit", &spec); | |
hk.register(key, move || println!("{} pressed!", &spec)).unwrap(); | |
stdin().read(&mut [0]).unwrap(); // wait for "enter" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment