code-scanner-driver 0.1.1

Driver for barcode scanners and keyboard input with GTIN validation, async streaming, and burst detection.
Documentation
use rdev::Key;

pub fn key_to_char(k: Key, hint: Option<&str>) -> Option<char> {
    if let Some(h) = hint {
        if h.len() == 1 {
            return h.chars().next();
        }
    }

    use Key::*;
    Some(match k {
        Num0 => '0', Num1 => '1', Num2 => '2', Num3 => '3', Num4 => '4',
        Num5 => '5', Num6 => '6', Num7 => '7', Num8 => '8', Num9 => '9',

        KeyA => 'a', KeyB => 'b', KeyC => 'c', KeyD => 'd', KeyE => 'e',
        KeyF => 'f', KeyG => 'g', KeyH => 'h', KeyI => 'i', KeyJ => 'j',
        KeyK => 'k', KeyL => 'l', KeyM => 'm', KeyN => 'n', KeyO => 'o',
        KeyP => 'p', KeyQ => 'q', KeyR => 'r', KeyS => 's', KeyT => 't',
        KeyU => 'u', KeyV => 'v', KeyW => 'w', KeyX => 'x', KeyY => 'y',
        KeyZ => 'z',

        Space => ' ',
        Minus => '-',
        Equal => '=',
        Comma => ',',
        Dot => '.',
        Slash => '/',
        BackSlash => '\\',

        _ => return None,
    })
}