#keyboard-layout #hid #keyboard #mapping #layout

no-std key-mapping

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

8 releases (4 breaking)

0.4.1 Sep 27, 2024
0.4.0 May 2, 2024
0.3.0 Apr 21, 2024
0.2.2 Apr 21, 2024
0.0.0 Apr 19, 2024

#717 in Encoding

Download history 7/week @ 2024-09-20 127/week @ 2024-09-27 11/week @ 2024-10-04 10/week @ 2024-10-11 2/week @ 2024-10-18

401 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.4–1.7MB
~34K SLoC