#linux #hashmap #lazy-static #input-event-codes


Hashmaps to look up the u32 value for a given input event code

1 unstable release

0.1.1 Oct 12, 2020
0.1.0 Sep 5, 2020

#513 in Unix APIs

Download history 2/week @ 2023-05-28 2/week @ 2023-06-11 3/week @ 2023-06-18 2/week @ 2023-06-25 2/week @ 2023-07-02 5/week @ 2023-07-09 3/week @ 2023-07-16 5/week @ 2023-07-23 3/week @ 2023-07-30 5/week @ 2023-08-06 7/week @ 2023-08-13 83/week @ 2023-08-20 55/week @ 2023-08-27 11/week @ 2023-09-03

156 downloads per month


877 lines


This crate provides HashMaps to look up the u32 value for a given input event code. The lazy-static crate is used so they are only created, if you used them. The codes are taken from input-event-codes.h.


There are the HashMaps ABS, BTN, EV, INPUT_PROP, KEY, LED, MSC, REL, REP, SND, SW and SYN. The prefix tells you which HashMap to use. If you are looking for KEY_T, you want to search in the KEY HashMap for "T". No need to repeat the prefix. There is an example on how to find the u32 value for KEY_T. It's as easy as:

use input_event_codes_hashmap::KEY;

fn main() {
    let keycode_name = "T";
    if let Some(keycode_value) = KEY.get(keycode_name) {
        println!("The u32 value for {} is {}", keycode_name, keycode_value);
    } else {
        println!("The u32 value could not be found");

You can run the example by entering the following command:

cargo run --example example


PRs are always welcome! If I made a mistake please tell me as well :)