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).