Skip to main content

IcedEventExt

Trait IcedEventExt 

Source
pub trait IcedEventExt: Sealed {
    // Required method
    fn to_hotkey(&self) -> Option<Hotkey>;
}
Expand description

Convert an iced keyboard Event to a kbd Hotkey.

Uses the physical key from the event for layout-independent matching. Returns None for ModifiersChanged events (no key trigger) and for events with unidentified physical keys.

When the key is itself a modifier (e.g., ControlLeft), the corresponding modifier flag is stripped from the modifiers — iced includes the pressed modifier key in its own modifier state, but kbd treats the key as the trigger, not as a modifier of itself. This trait is sealed and cannot be implemented outside this crate.

Required Methods§

Source

fn to_hotkey(&self) -> Option<Hotkey>

Convert this keyboard event to a Hotkey, or None if unmappable.

§Examples
use iced_core::keyboard::{Event, Location, Modifiers, key};
use kbd::prelude::*;
use kbd_iced::IcedEventExt;

let event = Event::KeyPressed {
    key: iced_core::keyboard::Key::Unidentified,
    modified_key: iced_core::keyboard::Key::Unidentified,
    physical_key: key::Physical::Code(key::Code::KeyS),
    location: Location::Standard,
    modifiers: Modifiers::CTRL,
    text: None,
    repeat: false,
};
assert_eq!(
    event.to_hotkey(),
    Some(Hotkey::new(Key::S).modifier(Modifier::Ctrl)),
);

Implementations on Foreign Types§

Source§

impl IcedEventExt for Event

Implementors§