Expand description
“Composite” keys; an aggregate type used for a common context and event.
This module implements the keymap::Key
for a ‘composite’ key,
which can be any of the other key definitions,
and is the default Key for the keymap::KeyMap
implementation.
§Keyboard variant
§JSON
use smart_keymap::key;
use key::{composite, keyboard};
type Ctx = composite::Context;
type Key = composite::BaseKey;
let json = r#"
{ "key_code": 4 }
"#;
let expected_key: Key = Key::keyboard(keyboard::Key::new(0x04));
let actual_key: Key = serde_json::from_str(json).unwrap();
assert_eq!(expected_key, actual_key);
§TapHold variant
§JSON
use smart_keymap::key;
use key::{composite, keyboard, layered, tap_hold};
type Ctx = composite::Context;
type Key = composite::TapHoldKey<composite::BaseKey>;
let json = r#"
{ "hold": { "key_code": 224 }, "tap": { "key_code": 4 } }
"#;
let expected_key: Key = Key::tap_hold(tap_hold::Key {
tap: keyboard::Key::new(4).into(),
hold: keyboard::Key::new(224).into(),
});
let actual_key: Key = serde_json::from_str(json).unwrap();
assert_eq!(expected_key, actual_key);
§Layer Modifier Key variant
§JSON
use smart_keymap::key;
use key::{composite, layered};
type Ctx = composite::Context;
type Key = composite::BaseKey;
let json = r#"
{ "Hold": 2 }
"#;
let expected_key: Key = Key::layer_modifier(layered::ModifierKey::Hold(2));
let actual_key: Key = serde_json::from_str(json).unwrap();
assert_eq!(expected_key, actual_key);
§Layered Key variant
§JSON
use smart_keymap::key;
use key::{composite, keyboard, layered};
type Ctx = composite::Context;
type Key = composite::LayeredKey<composite::TapHoldKey<composite::BaseKey>>;
let json = r#"
{
"base": { "key_code": 4 },
"layered": [{ "key_code": 5 }, null, { "key_code": 7 }]
}
"#;
let expected_key: Key = Key::layered(layered::LayeredKey::new(
keyboard::Key::new(0x04).into(),
[Some(keyboard::Key::new(0x05).into()), None, Some(keyboard::Key::new(0x07).into())],
));
let actual_key: Key = serde_json::from_str(json).unwrap();
assert_eq!(expected_key, actual_key);
Structs§
- Config used for constructing initial context
- An aggregate context for key::Contexts.
- Aggregates the key::PressedKeyState types.
Enums§
- An aggregate of key::Key types.
- Aggregates the key::PressedKeyState types.
- An aggregate of key::Key types.
- Aggregates the key::PressedKeyState types.
- Sum type aggregating the key::Event types.
- An aggregate of key::Key types.
- An aggregate of key::Key types.
- Aggregates the key::PressedKeyState types.
Constants§
- The default config.
- The default context.
Traits§
- Trait for types which can be nested in ChordedKey variants.
- Trait for types which can be nested in LayeredKey variants.
- Trait for types which can be nested in TapHoldKey variants.
Type Aliases§
- Convenience type alias for a key::PressedKey with a base key.
- Convenience type alias for a key::PressedKey with a layered key.
- Type alias for composite key types.
- Convenience type alias for a key::PressedKey with a layered key.
- Convenience type alias for the ‘highest’ composite key.
- Convenience type alias for a key::PressedKey with a taphold key.