k_board 1.2.0

A keyboard event handler that allows dynamic development
Documentation
pub const BYTES: usize = 3;

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum Keys {
    Up,
    Down,
    Left,
    Right,
    Enter,
    Home,
    Tab,
    Backtab,
    Space,
    Delete,
    Escape,
    End,
    Char(char),
    F(u8),
    Ctrl(char),
    Alt(char),
    Null,
}

pub const ARROWS_ENTER: [([u8; BYTES], Keys); 5] = [
    ([0x1B, 0x5B, 0x41], Keys::Up),
    ([0x1B, 0x5B, 0x42], Keys::Down),
    ([0x1B, 0x5B, 0x43], Keys::Right),
    ([0x1B, 0x5B, 0x44], Keys::Left),
    ([0x0A, 0x00, 0x00], Keys::Enter),
];

pub const STANDAR: [([u8; BYTES], Keys); 39] = [
    ([0x1B, 0x5B, 0x48], Keys::Home),
    ([0x09, 0x00, 0x00], Keys::Tab),
    ([0x1B, 0x5B, 0x46], Keys::End),
    ([0x1B, 0x5B, 0x5a], Keys::Backtab),
    ([0x20, 0x00, 0x00], Keys::Space),
    ([0x7F, 0x00, 0x00], Keys::Delete),
    ([0x2b, 0x00, 0x00], Keys::Char('+')),
    ([0x2d, 0x00, 0x00], Keys::Char('-')),
    ([0x3d, 0x00, 0x00], Keys::Char('=')),
    ([0x2f, 0x00, 0x00], Keys::Char('/')),
    ([0x5c, 0x00, 0x00], Keys::Char('\\')),
    ([0x5e, 0x00, 0x00], Keys::Char('^')),
    ([0x2a, 0x00, 0x00], Keys::Char('*')),
    ([0x2e, 0x00, 0x00], Keys::Char('.')),
    ([0x2c, 0x00, 0x00], Keys::Char(',')),
    ([0x23, 0x00, 0x00], Keys::Char('#')),
    ([0x26, 0x00, 0x00], Keys::Char('&')),
    ([0x25, 0x00, 0x00], Keys::Char('%')),
    ([0x7c, 0x00, 0x00], Keys::Char('|')),
    ([0x24, 0x00, 0x00], Keys::Char('$')),
    ([0x3a, 0x00, 0x00], Keys::Char(':')),
    ([0x3b, 0x00, 0x00], Keys::Char(';')),
    ([0xc2, 0xbf, 0x00], Keys::Char('¿')),
    ([0x3f, 0x00, 0x00], Keys::Char('?')),
    ([0x5b, 0x00, 0x00], Keys::Char('[')),
    ([0x5d, 0x00, 0x00], Keys::Char(']')),
    ([0x7b, 0x00, 0x00], Keys::Char('{')),
    ([0x7d, 0x00, 0x00], Keys::Char('}')),
    ([0x28, 0x00, 0x00], Keys::Char('(')),
    ([0x29, 0x00, 0x00], Keys::Char(')')),
    ([0x3c, 0x00, 0x00], Keys::Char('<')),
    ([0x3e, 0x00, 0x00], Keys::Char('>')),
    ([0x27, 0x00, 0x00], Keys::Char('\'')),
    ([0x40, 0x00, 0x00], Keys::Char('@')),
    ([0xc2, 0xa1, 0x0], Keys::Char('¡')),
    ([0x21, 0x00, 0x00], Keys::Char('!')),
    ([0x22, 0x0, 0x0], Keys::Char('"')),
    ([0x60, 0x0, 0x0], Keys::Char('`')),
    ([0xc2, 0xb4, 0x00], Keys::Char('´')),
];

pub const NUMBERS: [([u8; BYTES], Keys); 10] = [
    ([0x30, 0x00, 0x00], Keys::Char('0')),
    ([0x31, 0x00, 0x00], Keys::Char('1')),
    ([0x32, 0x00, 0x00], Keys::Char('2')),
    ([0x33, 0x00, 0x00], Keys::Char('3')),
    ([0x34, 0x00, 0x00], Keys::Char('4')),
    ([0x35, 0x00, 0x00], Keys::Char('5')),
    ([0x36, 0x00, 0x00], Keys::Char('6')),
    ([0x37, 0x00, 0x00], Keys::Char('7')),
    ([0x38, 0x00, 0x00], Keys::Char('8')),
    ([0x39, 0x00, 0x00], Keys::Char('9')),
];

pub const LOWER_LETTERS: [([u8; BYTES], Keys); 27] = [
    ([0x61, 0x00, 0x00], Keys::Char('a')),
    ([0x62, 0x00, 0x00], Keys::Char('b')),
    ([0x63, 0x00, 0x00], Keys::Char('c')),
    ([0x64, 0x00, 0x00], Keys::Char('d')),
    ([0x65, 0x00, 0x00], Keys::Char('e')),
    ([0x66, 0x00, 0x00], Keys::Char('f')),
    ([0x67, 0x00, 0x00], Keys::Char('g')),
    ([0x68, 0x00, 0x00], Keys::Char('h')),
    ([0x69, 0x00, 0x00], Keys::Char('i')),
    ([0x6A, 0x00, 0x00], Keys::Char('j')),
    ([0x6B, 0x00, 0x00], Keys::Char('k')),
    ([0x6C, 0x00, 0x00], Keys::Char('l')),
    ([0x6D, 0x00, 0x00], Keys::Char('m')),
    ([0x6E, 0x00, 0x00], Keys::Char('n')),
    ([0xb1, 0xb1, 0x00], Keys::Char('ñ')),
    ([0x6F, 0x00, 0x00], Keys::Char('o')),
    ([0x70, 0x00, 0x00], Keys::Char('p')),
    ([0x71, 0x00, 0x00], Keys::Char('q')),
    ([0x72, 0x00, 0x00], Keys::Char('r')),
    ([0x73, 0x00, 0x00], Keys::Char('s')),
    ([0x74, 0x00, 0x00], Keys::Char('t')),
    ([0x75, 0x00, 0x00], Keys::Char('u')),
    ([0x76, 0x00, 0x00], Keys::Char('v')),
    ([0x77, 0x00, 0x00], Keys::Char('w')),
    ([0x78, 0x00, 0x00], Keys::Char('x')),
    ([0x79, 0x00, 0x00], Keys::Char('y')),
    ([0x7A, 0x00, 0x00], Keys::Char('z')),
];

pub const UPPER_LETTER: [([u8; BYTES], Keys); 27] = [
    ([0x41, 0x00, 0x00], Keys::Char('A')),
    ([0x42, 0x00, 0x00], Keys::Char('B')),
    ([0x43, 0x00, 0x00], Keys::Char('C')),
    ([0x44, 0x00, 0x00], Keys::Char('D')),
    ([0x45, 0x00, 0x00], Keys::Char('E')),
    ([0x46, 0x00, 0x00], Keys::Char('F')),
    ([0x47, 0x00, 0x00], Keys::Char('G')),
    ([0x48, 0x00, 0x00], Keys::Char('H')),
    ([0x49, 0x00, 0x00], Keys::Char('I')),
    ([0x4A, 0x00, 0x00], Keys::Char('J')),
    ([0x4B, 0x00, 0x00], Keys::Char('K')),
    ([0x4C, 0x00, 0x00], Keys::Char('L')),
    ([0x4D, 0x00, 0x00], Keys::Char('M')),
    ([0x4E, 0x00, 0x00], Keys::Char('N')),
    ([0xb1, 0x91, 0x00], Keys::Char('Ñ')),
    ([0x4F, 0x00, 0x00], Keys::Char('O')),
    ([0x50, 0x00, 0x00], Keys::Char('P')),
    ([0x51, 0x00, 0x00], Keys::Char('Q')),
    ([0x52, 0x00, 0x00], Keys::Char('R')),
    ([0x53, 0x00, 0x00], Keys::Char('S')),
    ([0x54, 0x00, 0x00], Keys::Char('T')),
    ([0x55, 0x00, 0x00], Keys::Char('U')),
    ([0x56, 0x00, 0x00], Keys::Char('V')),
    ([0x57, 0x00, 0x00], Keys::Char('W')),
    ([0x58, 0x00, 0x00], Keys::Char('X')),
    ([0x59, 0x00, 0x00], Keys::Char('Y')),
    ([0x5A, 0x00, 0x00], Keys::Char('Z')),
];

pub const F: [([u8; BYTES], Keys); 12] = [
    ([0x1b, 0x4f, 0x50], Keys::F(1)),
    ([0x1b, 0x4f, 0x51], Keys::F(2)),
    ([0x1b, 0x4f, 0x52], Keys::F(3)),
    ([0x1b, 0x4f, 0x53], Keys::F(4)),
    ([0x35, 0x7E, 0x00], Keys::F(5)),
    ([0x37, 0x7E, 0x00], Keys::F(6)),
    ([0x38, 0x7E, 0x00], Keys::F(7)),
    ([0x39, 0x7E, 0x00], Keys::F(8)),
    ([0x30, 0x7E, 0x00], Keys::F(9)),
    ([0x31, 0x7E, 0x00], Keys::F(10)),
    ([0x33, 0x7E, 0x00], Keys::F(11)),
    ([0x34, 0x7E, 0x00], Keys::F(12)),
];

pub const CTRL_LOWER_LETTER: [([u8; BYTES], Keys); 24] = [
    ([0x01, 0x00, 0x00], Keys::Ctrl('a')),
    ([0x02, 0x00, 0x00], Keys::Ctrl('b')),
    ([0x03, 0x00, 0x00], Keys::Ctrl('c')),
    ([0x04, 0x00, 0x00], Keys::Ctrl('d')),
    ([0x05, 0x00, 0x00], Keys::Ctrl('e')),
    ([0x06, 0x00, 0x00], Keys::Ctrl('f')),
    ([0x07, 0x00, 0x00], Keys::Ctrl('g')),
    ([0x08, 0x00, 0x00], Keys::Ctrl('h')),
    ([0x0B, 0x00, 0x00], Keys::Ctrl('k')),
    ([0x0C, 0x00, 0x00], Keys::Ctrl('l')),
    ([0x0D, 0x00, 0x00], Keys::Ctrl('m')),
    ([0x0E, 0x00, 0x00], Keys::Ctrl('n')),
    ([0x0F, 0x00, 0x00], Keys::Ctrl('o')),
    ([0x10, 0x00, 0x00], Keys::Ctrl('p')),
    ([0x11, 0x00, 0x00], Keys::Ctrl('q')),
    ([0x12, 0x00, 0x00], Keys::Ctrl('r')),
    ([0x13, 0x00, 0x00], Keys::Ctrl('s')),
    ([0x14, 0x00, 0x00], Keys::Ctrl('t')),
    ([0x15, 0x00, 0x00], Keys::Ctrl('u')),
    ([0x16, 0x00, 0x00], Keys::Ctrl('v')),
    ([0x17, 0x00, 0x00], Keys::Ctrl('w')),
    ([0x18, 0x00, 0x00], Keys::Ctrl('x')),
    ([0x19, 0x00, 0x00], Keys::Ctrl('y')),
    ([0x1A, 0x00, 0x00], Keys::Ctrl('z')),
];

pub const ALT_LOWER_LETTER: [([u8; BYTES], Keys); 27] = [
    ([0x1b, 0x61, 0x00], Keys::Alt('a')),
    ([0x1b, 0x62, 0x00], Keys::Alt('b')),
    ([0x1b, 0x63, 0x00], Keys::Alt('c')),
    ([0x1b, 0x64, 0x00], Keys::Alt('d')),
    ([0x1b, 0x65, 0x00], Keys::Alt('e')),
    ([0x1b, 0x66, 0x00], Keys::Alt('f')),
    ([0x1b, 0x67, 0x00], Keys::Alt('g')),
    ([0x1b, 0x68, 0x00], Keys::Alt('h')),
    ([0x1b, 0x69, 0x00], Keys::Alt('i')),
    ([0x1b, 0x6A, 0x00], Keys::Alt('j')),
    ([0x1b, 0x6B, 0x00], Keys::Alt('k')),
    ([0x1b, 0x6C, 0x00], Keys::Alt('l')),
    ([0x1b, 0x6d, 0x00], Keys::Alt('m')),
    ([0x1b, 0x6e, 0x00], Keys::Alt('n')),
    ([0x1b, 0xc3, 0xb1], Keys::Alt('ñ')),
    ([0x1b, 0x6f, 0x00], Keys::Alt('o')),
    ([0x1b, 0x70, 0x00], Keys::Alt('p')),
    ([0x1b, 0x71, 0x00], Keys::Alt('q')),
    ([0x1b, 0x72, 0x00], Keys::Alt('r')),
    ([0x1b, 0x73, 0x00], Keys::Alt('s')),
    ([0x1b, 0x74, 0x00], Keys::Alt('t')),
    ([0x1b, 0x75, 0x00], Keys::Alt('u')),
    ([0x1b, 0x76, 0x00], Keys::Alt('v')),
    ([0x1b, 0x77, 0x00], Keys::Alt('w')),
    ([0x1b, 0x78, 0x00], Keys::Alt('x')),
    ([0x1b, 0x79, 0x00], Keys::Alt('y')),
    ([0x1b, 0x7a, 0x00], Keys::Alt('z')),
];