All tests run on an 8-year-old MacBook Air.
A global shortcut fires even when your app isn't focused. For a menubar app, this is essential — Cmd+Shift+H should open the panel regardless of what the user is doing.
Tauri v2 has a global shortcut plugin. It works, but there are a few things worth knowing before you reach for it.
Basic setup
# Cargo.toml [dependencies] tauri-plugin-global-shortcut = "2"
Enter fullscreen mode
Exit fullscreen mode
use tauri_plugin_global_shortcut ::{ GlobalShortcutExt , Shortcut };
fn main () { tauri :: Builder :: default () .plugin ( tauri_plugin_global_shortcut :: Builder :: new () .build ()) .setup (| app | { let shortcut : Shortcut = "CmdOrCtrl+Shift+H" .parse () ? ;
app .global_shortcut () .on_shortcut ( shortcut , | app , _shortcut , _event | { if let Some ( window ) = app .get_webview_window ( "main" ) { if window .is_visible () .unwrap_or ( false ) { window .hide () .unwrap (); } else { window .show () .unwrap (); window .set_focus () .unwrap (); } } }) ?…