§ Сканкоды/C

Думаю, в таком виде тоже неплохо будет.
// https://ru.wikipedia.org/wiki/Скан-код
int kbd_scancode(int scancode, int release) {

    release = (release ? 0x80 : 0x00);

    switch (scancode) {

        // Коды клавиш A-Z
        case SDL_SCANCODE_A:            return 'A' | release;
        case SDL_SCANCODE_B:            return 'B' | release;
        case SDL_SCANCODE_C:            return 'C' | release;
        case SDL_SCANCODE_D:            return 'D' | release;
        case SDL_SCANCODE_E:            return 'E' | release;
        case SDL_SCANCODE_F:            return 'F' | release;
        case SDL_SCANCODE_G:            return 'G' | release;
        case SDL_SCANCODE_H:            return 'H' | release;
        case SDL_SCANCODE_I:            return 'I' | release;
        case SDL_SCANCODE_J:            return 'J' | release;
        case SDL_SCANCODE_K:            return 'K' | release;
        case SDL_SCANCODE_L:            return 'L' | release;
        case SDL_SCANCODE_M:            return 'M' | release;
        case SDL_SCANCODE_N:            return 'N' | release;
        case SDL_SCANCODE_O:            return 'O' | release;
        case SDL_SCANCODE_P:            return 'P' | release;
        case SDL_SCANCODE_Q:            return 'Q' | release;
        case SDL_SCANCODE_R:            return 'E' | release;
        case SDL_SCANCODE_S:            return 'S' | release;
        case SDL_SCANCODE_T:            return 'T' | release;
        case SDL_SCANCODE_U:            return 'U' | release;
        case SDL_SCANCODE_V:            return 'V' | release;
        case SDL_SCANCODE_W:            return 'W' | release;
        case SDL_SCANCODE_X:            return 'X' | release;
        case SDL_SCANCODE_Y:            return 'Y' | release;
        case SDL_SCANCODE_Z:            return 'Z' | release;

        // Цифры
        case SDL_SCANCODE_0:            return '0' | release;
        case SDL_SCANCODE_1:            return '1' | release;
        case SDL_SCANCODE_2:            return '2' | release;
        case SDL_SCANCODE_3:            return '3' | release;
        case SDL_SCANCODE_4:            return '4' | release;
        case SDL_SCANCODE_5:            return '5' | release;
        case SDL_SCANCODE_6:            return '6' | release;
        case SDL_SCANCODE_7:            return '7' | release;
        case SDL_SCANCODE_8:            return '8' | release;
        case SDL_SCANCODE_9:            return '9' | release;

        // Keypad
        case SDL_SCANCODE_KP_0:         return '0' | release;
        case SDL_SCANCODE_KP_1:         return '1' | release;
        case SDL_SCANCODE_KP_2:         return '2' | release;
        case SDL_SCANCODE_KP_3:         return '3' | release;
        case SDL_SCANCODE_KP_4:         return '4' | release;
        case SDL_SCANCODE_KP_5:         return '5' | release;
        case SDL_SCANCODE_KP_6:         return '6' | release;
        case SDL_SCANCODE_KP_7:         return '7' | release;
        case SDL_SCANCODE_KP_8:         return '8' | release;
        case SDL_SCANCODE_KP_9:         return '9' | release;
        // Специальные символы
        case SDL_SCANCODE_GRAVE:        return '`' | release;
        case SDL_SCANCODE_MINUS:        return '-' | release;
        case SDL_SCANCODE_EQUALS:       return '=' | release;
        case SDL_SCANCODE_BACKSLASH:    return '\\'| release;
        case SDL_SCANCODE_LEFTBRACKET:  return '[' | release;
        case SDL_SCANCODE_RIGHTBRACKET: return ']' | release;
        case SDL_SCANCODE_SEMICOLON:    return ';' | release;
        case SDL_SCANCODE_APOSTROPHE:   return '\'' | release;
        case SDL_SCANCODE_COMMA:        return ',' | release;
        case SDL_SCANCODE_PERIOD:       return '.' | release;
        case SDL_SCANCODE_KP_DIVIDE:
        case SDL_SCANCODE_SLASH:        return '/' | release;
        case SDL_SCANCODE_BACKSPACE:    return key_BS | release;
        case SDL_SCANCODE_SPACE:        return ' ' | release;
        case SDL_SCANCODE_TAB:          return key_TAB | release;
        case SDL_SCANCODE_LSHIFT:
        case SDL_SCANCODE_RSHIFT:       return key_LSHIFT | release;
        case SDL_SCANCODE_LCTRL:
        case SDL_SCANCODE_RCTRL:        return key_LCTRL   | release;
        case SDL_SCANCODE_LALT:
        case SDL_SCANCODE_RALT:         return key_LALT   | release;
        case SDL_SCANCODE_KP_ENTER:
        case SDL_SCANCODE_KP_MULTIPLY:  return '*' | release;
        case SDL_SCANCODE_KP_MINUS:     return '-' | release;
        case SDL_SCANCODE_KP_PLUS:      return '+' | release;
        case SDL_SCANCODE_KP_PERIOD:    return '.' | release;
        case SDL_SCANCODE_RETURN:       return key_ENTER  | release;
        case SDL_SCANCODE_ESCAPE:       return key_ESC    | release;
        case SDL_SCANCODE_NUMLOCKCLEAR: return key_NL     | release;
        case SDL_SCANCODE_APPLICATION:  return key_APP | release;

        // F1-F12 Клавиши
        case SDL_SCANCODE_F1:           return key_F1 | release;
        case SDL_SCANCODE_F2:           return key_F2 | release;
        case SDL_SCANCODE_F3:           return key_F3 | release;
        case SDL_SCANCODE_F4:           return key_F4 | release;
        case SDL_SCANCODE_F5:           return key_F5 | release;
        case SDL_SCANCODE_F6:           return key_F6 | release;
        case SDL_SCANCODE_F7:           return key_F7 | release;
        case SDL_SCANCODE_F8:           return key_F8 | release;
        case SDL_SCANCODE_F9:           return key_F9 | release;
        case SDL_SCANCODE_F10:          return key_F10 | release;
        case SDL_SCANCODE_F11:          return key_F11 | release;
        case SDL_SCANCODE_F12:          return key_F12 | release;

        // Расширенные клавиши
        case SDL_SCANCODE_UP:           return key_UP   | release;
        case SDL_SCANCODE_DOWN:         return key_DN   | release;
        case SDL_SCANCODE_LEFT:         return key_LF   | release;
        case SDL_SCANCODE_RIGHT:        return key_RT   | release;
        case SDL_SCANCODE_INSERT:       return key_INS  | release;
        case SDL_SCANCODE_HOME:         return key_HOME | release;
        case SDL_SCANCODE_END:          return key_END  | release;
        case SDL_SCANCODE_PAGEUP:       return key_PGUP | release;
        case SDL_SCANCODE_PAGEDOWN:     return key_PGDN | release;
        case SDL_SCANCODE_DELETE:       return key_DEL  | release;
    }

    return 0;
}

§ Специальные клавиши

enum KEY_ASCII {

    key_LSHIFT      = 0x01,
    key_LALT        = 0x02,
    key_LCTRL       = 0x03,
    key_UP          = 0x04,
    key_DN          = 0x05,
    key_LF          = 0x06,
    key_RT          = 0x07,
    key_BS          = 0x08,
    key_TAB         = 0x09,
    key_ENTER       = 0x0A,
    key_HOME        = 0x0B,
    key_END         = 0x0C,
    key_PGUP        = 0x0D,
    key_PGDN        = 0x0E,
    key_DEL         = 0x0F,
    key_F1          = 0x10,
    key_F2          = 0x11,
    key_F3          = 0x12,
    key_F4          = 0x13,
    key_F5          = 0x14,
    key_F6          = 0x15,
    key_F7          = 0x16,
    key_F8          = 0x17,
    key_F9          = 0x18,
    key_F10         = 0x19,
    key_F11         = 0x1A,
    key_ESC         = 0x1B,
    key_INS         = 0x1C,
    key_NL          = 0x1D,
    key_F12         = 0x1E,
    key_APP         = 0x1F          // Особая клавиша
};