Crate key_mapping

Source
Expand description

key-mapping library allows for keyboard key code conversion between systems such as the DOM and HID usage-ids. With Rust [no_std] support.

§Features

Extra functionality is behind optional features to optimize compile time and binary size.

  • std (enabled by default) - Add support for Rust’s libstd types.
  • serde Add support for serde de/serializing library.
  • usbd-hid Add support for converting between the usbd-hid library KeyboardReport.

§Example Usage

[dependencies]
key-mapping = "0.4"
use key_mapping::Keyboard;

fn main() {
    let dom_code = "KeyA";
    let usage_id = Keyboard::US.dom_key_to_usage_id(dom_code).unwrap();

    assert_eq!(0x04, *usage_id);
}

Structs§

KeyboardAction
A keyboard action, could be used for making key press/release events, Defaults to no keys or modifiers.
MappedKey
A single mapped keyboard key.

Enums§

Keyboard
Keyboard layouts, used to convert between key-code types.
Keys
Keyboard keys as enum values, with usage-id representation.

Constants§

MODIFIER_CODE_ALT
MODIFIER_CODE_CTRL
MODIFIER_CODE_META
MODIFIER_CODE_SHIFT

Statics§

DOM_KEYS_UK
DOM key to usage-id map for the UK layout.
DOM_KEYS_US
DOM key to usage-id map for the US layout.
MAPPED_KEYS
usage-id to mapped key info.