pub trait Key: Debug {
type Context: Copy;
type Event: Copy + Debug + PartialEq;
type PressedKey: PressedKey<Context = Self::Context, Event = Self::Event>;
// Required method
fn new_pressed_key(
&self,
context: Self::Context,
keymap_index: u16,
) -> (Self::PressedKey, PressedKeyEvents<Self::Event>);
}
Expand description
The interface for Key
behaviour.
A Key
has an associated Context, Event
, and PressedKeyState.
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§
Sourcetype Context: Copy
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).
Sourcetype Event: Copy + Debug + PartialEq
type Event: Copy + Debug + PartialEq
The associated Event
is to be handled by the associated Context,
and any active PressedKeys.
Sourcetype PressedKey: PressedKey<Context = Self::Context, Event = Self::Event>
type PressedKey: PressedKey<Context = Self::Context, Event = Self::Event>
The associated PressedKeyState implements functionality for the pressed key. (e.g. tap_hold::PressedKeyState implements behaviour resolving the pressed tap hold key as either ‘tap’ or ‘hold’).
Required Methods§
Sourcefn new_pressed_key(
&self,
context: Self::Context,
keymap_index: u16,
) -> (Self::PressedKey, PressedKeyEvents<Self::Event>)
fn new_pressed_key( &self, context: Self::Context, keymap_index: u16, ) -> (Self::PressedKey, PressedKeyEvents<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).