#keyboard #hid #keyboard-layout #mapping #layout #no-alloc

no-std key-mapping

Library allowing for keyboard key code conversion between systems such as the DOM and HID usage-ids

7 releases (4 breaking)

new 0.4.0 May 2, 2024
0.3.0 Apr 21, 2024
0.2.2 Apr 21, 2024
0.1.0 Apr 19, 2024
0.0.0 Apr 19, 2024

#10 in #keyboard-layout

Download history 303/week @ 2024-04-15 138/week @ 2024-04-22

441 downloads per month

MIT/Apache

13KB
276 lines

key-mapping

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

License

Dual licensed under either Apache License, Version 2.0 or MIT license at your option.


lib.rs:

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);
}

Dependencies

~0.5–1.5MB
~33K SLoC