tauri_sys::global_shortcut

Function register

Source
pub async fn register(shortcut: &str) -> Result<impl Stream<Item = ()>, Error>
Expand description

Register a global shortcut.

The returned Future will automatically clean up it’s underlying event listener when dropped, so no manual unlisten function needs to be called. See Differences to the JavaScript API for details.

§Examples

use tauri_sys::global_shortcut::register;
use web_sys::console;

let events = register("CommandOrControl+Shift+C").await?;

while let Some(_) in events.next().await {
    console::log_1(&"Shortcut triggered".into());
}