kbt 1.2.2

Keyboard tester in terminal
use std::fmt;

#[derive(Debug, Eq, Hash, PartialEq)]
pub enum Key {
    Q,
    W,
    E,
    R,
    T,
    Y,
    U,
    I,
    O,
    P,
    A,
    S,
    D,
    F,
    G,
    H,
    J,
    K,
    L,
    Z,
    X,
    C,
    V,
    B,
    N,
    M,

    // numbers
    One,
    Two,
    Three,
    Four,
    Five,
    Six,
    Seven,
    Eight,
    Nine,
    Zero,

    // symbols
    Grave,
    Hyphen,
    Plus,
    LeftBracket,
    RightBracket,
    Backslash,
    SemiColon,
    Apostrophe,
    Comma,
    Period,
    QuestionMark,

    // modifiers
    Esc,
    Tab,
    CapsLock,
    LeftShift,
    LeftCtrl,
    LeftSuper,
    LeftAlt,
    Spacebar,
    RightAlt,
    RightSuper,
    RightCtrl,
    RightShift,
    Return,
    Backspace,
    Insert,
    Home,
    PgUp,
    Delete,
    End,
    PgDown,

    Command,

    // arrows
    ArrowUp,
    ArrowDown,
    ArrowLeft,
    ArrowRight,

    // F keys
    F1,
    F2,
    F3,
    F4,
    F5,
    F6,
    F7,
    F8,
    F9,
    F10,
    F11,
    F12,

    // misc
    Separator,
    PrintScreen,
    ScrollLock,
    PauseBreak,

    Unknown,
}

impl fmt::Display for Key {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Key::CapsLock => write!(f, "Caps"),
            Key::Backspace => write!(f, "Back"),
            Key::LeftShift => write!(f, "Shift"),
            Key::LeftCtrl => write!(f, "Ctrl"),
            Key::LeftSuper => write!(f, "Super"),
            Key::LeftAlt => write!(f, "Alt"),
            Key::LeftBracket => write!(f, "{{["),
            Key::RightShift => write!(f, "Shift"),
            Key::RightCtrl => write!(f, "Ctrl"),
            Key::RightSuper => write!(f, "Super"),
            Key::RightAlt => write!(f, "Alt"),
            Key::RightBracket => write!(f, "}}]"),
            Key::Backslash => write!(f, "|\\"),
            Key::SemiColon => write!(f, ":;"),
            Key::Apostrophe => write!(f, "\"'"),
            Key::Comma => write!(f, "<,"),
            Key::Period => write!(f, ">."),
            Key::QuestionMark => write!(f, "?/"),
            Key::One => write!(f, "1"),
            Key::Two => write!(f, "2"),
            Key::Three => write!(f, "3"),
            Key::Four => write!(f, "4"),
            Key::Five => write!(f, "5"),
            Key::Six => write!(f, "6"),
            Key::Seven => write!(f, "7"),
            Key::Eight => write!(f, "8"),
            Key::Nine => write!(f, "9"),
            Key::Zero => write!(f, "0"),
            Key::Hyphen => write!(f, "-"),
            Key::Plus => write!(f, "+"),
            Key::Grave => write!(f, "~`"),
            Key::ArrowUp => write!(f, "↑"),
            Key::ArrowDown => write!(f, "↓"),
            Key::ArrowLeft => write!(f, "←"),
            Key::ArrowRight => write!(f, "→"),
            Key::PauseBreak => write!(f, "P/B"),
            Key::PrintScreen => write!(f, "Prn"),
            Key::ScrollLock => write!(f, "Lck"),
            Key::Separator => write!(f, ""),
            _ => write!(f, "{:?}", self),
        }
    }
}