pub struct HotkeyManager { /* private fields */ }Expand description
Platform-agnostic Hotkey Manager
This manager wraps a KeyboardListener and filters events against
registered hotkeys, emitting HotkeyEvents when matches occur.
Registered hotkeys are blocked from reaching other applications. Note: On Linux/Wayland, blocking may not work due to compositor restrictions.
Implementations§
Source§impl HotkeyManager
impl HotkeyManager
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new HotkeyManager (non-blocking mode)
On macOS, this will check for accessibility permissions and fail if not granted.
Sourcepub fn new_with_blocking() -> Result<Self>
pub fn new_with_blocking() -> Result<Self>
Create a new HotkeyManager with blocking support
On macOS, this will check for accessibility permissions and fail if not granted. Registered hotkeys will be blocked from reaching other applications.
Note: On Linux/Wayland, blocking may not work due to compositor restrictions.
Sourcepub fn register(&self, hotkey: Hotkey) -> Result<HotkeyId>
pub fn register(&self, hotkey: Hotkey) -> Result<HotkeyId>
Register a hotkey and return its unique ID
Returns an error if the hotkey is already registered.
Sourcepub fn unregister(&self, id: HotkeyId) -> Result<()>
pub fn unregister(&self, id: HotkeyId) -> Result<()>
Unregister a hotkey by its ID
Returns an error if the hotkey ID is not found.
Sourcepub fn get_hotkey(&self, id: HotkeyId) -> Option<Hotkey>
pub fn get_hotkey(&self, id: HotkeyId) -> Option<Hotkey>
Get the hotkey definition associated with an ID
Returns None if the ID is not found.
Sourcepub fn recv(&self) -> Result<HotkeyEvent>
pub fn recv(&self) -> Result<HotkeyEvent>
Blocking receive for hotkey events
Blocks until a hotkey event is received or the event loop stops.
Sourcepub fn try_recv(&self) -> Option<HotkeyEvent>
pub fn try_recv(&self) -> Option<HotkeyEvent>
Non-blocking receive for hotkey events
Returns Some(event) if an event is available, None otherwise.
Sourcepub fn hotkey_count(&self) -> usize
pub fn hotkey_count(&self) -> usize
Get the number of currently registered hotkeys