Trait Key

Source
pub trait Key: Debug {
    type Context: Copy;
    type Event: Copy + Debug + PartialEq;
    type PendingKeyState;
    type KeyState;

    // Required methods
    fn new_pressed_key(
        &self,
        context: &Self::Context,
        key_path: KeyPath,
    ) -> (PressedKeyResult<Self::PendingKeyState, Self::KeyState>, KeyEvents<Self::Event>);
    fn handle_event(
        &self,
        pending_state: &mut Self::PendingKeyState,
        context: &Self::Context,
        key_path: KeyPath,
        event: Event<Self::Event>,
    ) -> (Option<PressedKeyResult<Self::PendingKeyState, Self::KeyState>>, KeyEvents<Self::Event>);
    fn lookup(
        &self,
        path: &[u16],
    ) -> &dyn Key<Context = Self::Context, Event = Self::Event, PendingKeyState = Self::PendingKeyState, KeyState = Self::KeyState>;
}
Expand description

The interface for Key behaviour.

A Key has an associated Context, Event, and KeyState.

The generic PK is used as the type of the PressedKey that the Key produces. (e.g. layered::LayeredKey’s pressed key state passes-through to the keys of its layers).

Required Associated Types§

Source

type Context: Copy

The associated Context is used to provide state that may affect behaviour when pressing the key. (e.g. the behaviour of layered::LayeredKey depends on which layers are active in layered::Context).

Source

type Event: Copy + Debug + PartialEq

The associated Event is to be handled by the associated Context, pending key states, and key states.

Source

type PendingKeyState

Associated pending key state.

Source

type KeyState

Associated key state type.

Required Methods§

Source

fn new_pressed_key( &self, context: &Self::Context, key_path: KeyPath, ) -> (PressedKeyResult<Self::PendingKeyState, Self::KeyState>, KeyEvents<Self::Event>)

Key::new_pressed_key produces a pressed key value, and may yield some ScheduledEvents. (e.g. tap_hold::Key schedules a tap_hold::Event::TapHoldTimeout so that holding the key resolves as a hold).

Source

fn handle_event( &self, pending_state: &mut Self::PendingKeyState, context: &Self::Context, key_path: KeyPath, event: Event<Self::Event>, ) -> (Option<PressedKeyResult<Self::PendingKeyState, Self::KeyState>>, KeyEvents<Self::Event>)

Update the given pending key state with the given impl.

Source

fn lookup( &self, path: &[u16], ) -> &dyn Key<Context = Self::Context, Event = Self::Event, PendingKeyState = Self::PendingKeyState, KeyState = Self::KeyState>

Return a reference to the key for the given path.

Implementors§

Source§

impl Key for smart_keymap::key::caps_word::Key

Source§

impl Key for BaseKey

Source§

impl Key for ModifierKey

Source§

impl Key for smart_keymap::key::callback::Key

Source§

impl Key for smart_keymap::key::custom::Key

Source§

impl Key for smart_keymap::key::keyboard::Key

Source§

impl Key for smart_keymap::key::sticky::Key

Source§

impl<K: ChordedNestable> Key for ChordedKey<K>

Source§

impl<K: ChordedNestable> Key for Chorded<K>

Source§

impl<K: LayeredNestable> Key for smart_keymap::key::composite::LayeredKey<K>

Source§

impl<K: LayeredNestable> Key for Layered<K>

Source§

impl<K: TapHoldNestable> Key for TapHoldKey<K>

Source§

impl<K: TapHoldNestable> Key for TapHold<K>

Source§

impl<K: Key<Context = Context, Event = Event, PendingKeyState = PendingKeyState, KeyState = KeyState> + Copy + PartialEq> Key for smart_keymap::key::layered::LayeredKey<K>

Source§

impl<K: Key<Context = Context, Event = Event, PendingKeyState = PendingKeyState, KeyState = KeyState>> Key for AuxiliaryKey<K>

Source§

impl<K: Key<Context = Context, Event = Event, PendingKeyState = PendingKeyState, KeyState = KeyState>> Key for smart_keymap::key::chorded::Key<K>

Source§

impl<K: Key<Context = Context, Event = Event, PendingKeyState = PendingKeyState, KeyState = KeyState>> Key for smart_keymap::key::tap_dance::Key<K>

Source§

impl<K: Key<Context = Context, Event = Event, PendingKeyState = PendingKeyState, KeyState = KeyState>> Key for smart_keymap::key::tap_hold::Key<K>