nidium / Nidium

nidium is an ongoing effort for a mobile hw-accelerated rendering engine to create apps and games. Embedding Mozilla JavaScript VM, Google Skia, Facebook Yoga. https://twitter.com/nidiumproject for updates
https://www.nidium.com
Other
1.14k stars 63 forks source link

window._onkeydown: keyCodes are messed up, yo. #89

Open cookiengineer opened 6 years ago

cookiengineer commented 6 years ago

The keyCodes violate pretty much any API available, with random offsets. Here's a list of what I've found out so far:

Violations to ASCII charset:

Additional Notes:

Overall, there's plenty of bugs in the keycode API and special characters (like shift-1, or [ etc.) have totally different keycodes than the specs have. As those are too complicated and too exhausting to list, I am just posting my temporary working-except-above-bugs key mappings file here in the lychee.Input implementation. Take a look in my implementation for the _KEYMAP and _SPECIALMAP constants if direct link to line does not work.

cookiengineer commented 6 years ago

Here's a quick summary from my implementation notes, with expected keycodes and fired-by-nidium ones. Those might help with debugging and tracing down the bug:


const _KEYMAP = {

    // 45:  'insert', // XXX: nidium fires incorrect 73
    // 46:  'delete', // XXX: nidium fires incorrect 127

    // 112: 'f1',  // XXX: nidium fires incorrect 58
    // 113: 'f2',  // XXX: nidium fires incorrect 59
    // 114: 'f3',  // XXX: nidium fires incorrect 60
    // 115: 'f4',  // XXX: nidium fires incorrect 187
    // 116: 'f5',  // XXX: nidium fires incorrect 62
    // 117: 'f6',  // XXX: nidium fires incorrect 63
    // 118: 'f7',  // XXX: nidium fires incorrect 64
    // 119: 'f8',  // XXX: nidium fires incorrect 65
    // 120: 'f9',  // XXX: nidium fires incorrect 66
    // 121: 'f10', // XXX: nidium fires incorrect 67
    // 122: 'f11', // XXX: nidium fires incorrect 68
    // 123: 'f12'  // XXX: nidium fires incorrect 69

};

// Specialmap is structured like this (assuming en_US layout and/or OS keymap settings):
// entry[0] is normal press
// entry[1] is while pressing shift

const _SPECIALMAP = {

    48:  [ '0', ')' ],
    49:  [ '1', '!' ],
    50:  [ '2', '@' ],
    51:  [ '3', '#' ],
    52:  [ '4', '$' ],
    53:  [ '5', '%' ],
    54:  [ '6', '^' ],
    55:  [ '7', '&' ],
    56:  [ '8', '*' ],
    // 57:  [ '9', '(' ], // XXX: nidium fires incorrect 20

    // 186: [ ';', ':' ], // XXX: nidium fires incorrect 59
    187: [ '=', '+' ],
    188: [ ',', '<' ],
    189: [ '-', '_' ]
    // 190: [ '.', '>' ], // XXX: nidium fires incorrect 46
    // 191: [ '/', '?' ], // XXX: nidium fires incorrect 47
    // 192: [ '`', '~' ], // XXX: nidium fires incorrect 96

    // 219: [ '[',  '{' ], // XXX: nidium fires incirrect 91
    // 220: [ '\\', '|' ], // XXX: nidium fires incorrect 92
    // 221: [ ']',  '}' ], // XXX: nidium fires incorrect 93
    // 222: [ '\'', '"' ]  // XXX: nidium fires incorrect 39

};