Enum rmk::action::KeyAction

source ·
pub enum KeyAction {
    No,
    Transparent,
    Single(Action),
    Tap(Action),
    OneShot(Action),
    LayerTapHold(Action, u8),
    WithModifier(Action, ModifierCombination),
    ModifierTapHold(Action, ModifierCombination),
    TapHold(Action, Action),
}
Expand description

A KeyAction is the action at a keyboard position, stored in keymap. It can be a single action like triggering a key, or a composite keyboard action like tap/hold

Each KeyAction can be serialized to a u16 action code. There are 2 patterns of action code’s bit-field composition of KeyAction:

  • KeyActionType(8bits) + BasicAction(8bits)

  • KeyActionType(4bits) + Action(12bits)

The BasicAction represents only a single key action of keycodes defined in HID spec. The Action represents all actions defined in the following Action enum, including modifier combination and layer switch.

The KeyActionType bits varies between different types of a KeyAction, see docs of each enum variant.

Variants§

§

No

No action. Serialized as 0x0000.

§

Transparent

Transparent action, next layer will be checked. Serialized as 0x0001.

§

Single(Action)

A single action, such as triggering a key, or activating a layer. Action is triggered when pressed and cancelled when released.

Serialized as 0000|Action(12bits).

§

Tap(Action)

Don’t wait the release of the key, auto-release after a time threshold.

Serialized as 0001|Action(12bits).

§

OneShot(Action)

Keep current key pressed until the next key is triggered.

Serialized as 0010|Action(12bits).

§

LayerTapHold(Action, u8)

Layer tap/hold will trigger different actions: tap for basic action, hold for layer activation.

Serialized as 0011|layer(4bits)|BasicAction(8bits).

§

WithModifier(Action, ModifierCombination)

Action with the modifier combination triggered.

Serialized as 010|modifier(5bits)|BasicAction(8bits).

§

ModifierTapHold(Action, ModifierCombination)

Modifier tap/hold will trigger different actions: tap for basic action, hold for modifier activation.

Serialized as 011|modifier(5bits)|BasicAction(8bits).

§

TapHold(Action, Action)

General tap/hold action. Because current BaseAction actually uses at most 7 bits, so we borrow 1 bit as the identifier of general tap/hold action.

Serialized as 1|BasicAction(7bits)|BasicAction(8bits).

Trait Implementations§

source§

impl Clone for KeyAction

source§

fn clone(&self) -> KeyAction

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for KeyAction

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Format for KeyAction

source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
source§

impl PartialEq for KeyAction

source§

fn eq(&self, other: &KeyAction) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for KeyAction

source§

impl Eq for KeyAction

source§

impl StructuralPartialEq for KeyAction

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>,

§

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>,

§

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.