Skip to main content

HotkeyManager

Struct HotkeyManager 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn unregister(&self, id: HotkeyId) -> Result<()>

Unregister a hotkey by its ID

Returns an error if the hotkey ID is not found.

Source

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.

Source

pub fn recv(&self) -> Result<HotkeyEvent>

Blocking receive for hotkey events

Blocks until a hotkey event is received or the event loop stops.

Source

pub fn try_recv(&self) -> Option<HotkeyEvent>

Non-blocking receive for hotkey events

Returns Some(event) if an event is available, None otherwise.

Source

pub fn hotkey_count(&self) -> usize

Get the number of currently registered hotkeys

Trait Implementations§

Source§

impl Drop for HotkeyManager

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.