aumate 0.2.8

Cross-platform desktop automation library with GUI support
Documentation
//! Linux (X11) keycode to Key mapping

use crate::eventhooks::types::Key;

/// Convert Linux X11 keycode to Key
pub fn key_from_code(code: u32) -> Key {
    match code {
        9 => Key::Escape,
        10 => Key::Num1,
        11 => Key::Num2,
        12 => Key::Num3,
        13 => Key::Num4,
        14 => Key::Num5,
        15 => Key::Num6,
        16 => Key::Num7,
        17 => Key::Num8,
        18 => Key::Num9,
        19 => Key::Num0,
        20 => Key::Minus,
        21 => Key::Equal,
        22 => Key::Backspace,
        23 => Key::Tab,
        24 => Key::KeyQ,
        25 => Key::KeyW,
        26 => Key::KeyE,
        27 => Key::KeyR,
        28 => Key::KeyT,
        29 => Key::KeyY,
        30 => Key::KeyU,
        31 => Key::KeyI,
        32 => Key::KeyO,
        33 => Key::KeyP,
        34 => Key::LeftBracket,
        35 => Key::RightBracket,
        36 => Key::Return,
        37 => Key::ControlLeft,
        38 => Key::KeyA,
        39 => Key::KeyS,
        40 => Key::KeyD,
        41 => Key::KeyF,
        42 => Key::KeyG,
        43 => Key::KeyH,
        44 => Key::KeyJ,
        45 => Key::KeyK,
        46 => Key::KeyL,
        47 => Key::SemiColon,
        48 => Key::Quote,
        49 => Key::BackQuote,
        50 => Key::ShiftLeft,
        51 => Key::BackSlash,
        52 => Key::KeyZ,
        53 => Key::KeyX,
        54 => Key::KeyC,
        55 => Key::KeyV,
        56 => Key::KeyB,
        57 => Key::KeyN,
        58 => Key::KeyM,
        59 => Key::Comma,
        60 => Key::Dot,
        61 => Key::Slash,
        62 => Key::ShiftRight,
        63 => Key::KpMultiply,
        64 => Key::Alt,
        65 => Key::Space,
        66 => Key::CapsLock,
        67 => Key::F1,
        68 => Key::F2,
        69 => Key::F3,
        70 => Key::F4,
        71 => Key::F5,
        72 => Key::F6,
        73 => Key::F7,
        74 => Key::F8,
        75 => Key::F9,
        76 => Key::F10,
        77 => Key::NumLock,
        78 => Key::ScrollLock,
        79 => Key::Kp7,
        80 => Key::Kp8,
        81 => Key::Kp9,
        82 => Key::KpMinus,
        83 => Key::Kp4,
        84 => Key::Kp5,
        85 => Key::Kp6,
        86 => Key::KpPlus,
        87 => Key::Kp1,
        88 => Key::Kp2,
        89 => Key::Kp3,
        90 => Key::Kp0,
        91 => Key::KpDecimal,
        94 => Key::IntlBackslash,
        95 => Key::F11,
        96 => Key::F12,
        0x61 => Key::IntlRo,
        0x62 => Key::Lang3,
        0x63 => Key::Lang4,
        0x64 => Key::Lang2,
        0x65 => Key::KanaMode,
        0x66 => Key::Lang1,
        0x79 => Key::VolumeMute,
        0x7A => Key::VolumeDown,
        0x7B => Key::VolumeUp,
        0x7D => Key::KpEqual,
        0x81 => Key::KpComma,
        0x84 => Key::IntlYen,
        104 => Key::KpReturn,
        105 => Key::ControlRight,
        106 => Key::KpDivide,
        107 => Key::PrintScreen,
        108 => Key::AltGr,
        110 => Key::Home,
        111 => Key::UpArrow,
        112 => Key::PageUp,
        113 => Key::LeftArrow,
        114 => Key::RightArrow,
        115 => Key::End,
        116 => Key::DownArrow,
        117 => Key::PageDown,
        118 => Key::Insert,
        119 => Key::Delete,
        127 => Key::Pause,
        133 => Key::MetaLeft,
        134 => Key::MetaRight,
        135 => Key::Apps,
        0x5D => Key::Lang5,
        0xBF => Key::F13,
        0xC0 => Key::F14,
        0xC1 => Key::F15,
        0xC2 => Key::F16,
        0xC3 => Key::F17,
        0xC4 => Key::F18,
        0xC5 => Key::F19,
        0xC6 => Key::F20,
        0xC7 => Key::F21,
        0xC8 => Key::F22,
        0xC9 => Key::F23,
        0xCA => Key::F24,
        _ => Key::Unknown(code),
    }
}