Skip to content

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

@cookiengineer

Description

@cookiengineer

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:

  • F1 - F12 are offseted incorrectly, so F1 to F3 work correctly (with incorrect keyCodes 58-60)
  • F4 has the keyCode 187 (= or +) which doesn't make any sense.
  • F5 and upwards are identical keyCodes as a and later letters on the keyboard, so they do conflict with the ASCII range and therefore cannot be used in their current state.
  • 9 or shift-9 will lead to keycode 20 (capslock) which is incorrect and should be 57.
  • page-up will lead to keycode 75 ("k") which is incorrect and should be 33.
  • page-down will lead to keycode 78 ("n") which is incorrect and should be 34.
  • pos1 (or begin or home) will lead to keycode 74 ("j") which is incorrect.
  • end will lead to keycode 77 ("m") which is incorrect and should be 35.
  • insert (or ins) will lead to keycode 73 ("i") which is incorrect and should be 45.
  • delete (or entf) will lead to keycode 127 which is incorrect and should be 46.

Additional Notes:

  • The F1-F12 keys normally have the keycodes 112 (F1) to 123 (F12) to not conflict with the ASCII key range.

  • The special characters (0-9 keys on keyboard) are typically in the range of 48 - 57, because of ASCII charset compatibility. In nidium, this is incorrect, too.

  • Other special characters ([];'\,./ keys) typically are in the range of 186-192 and 219-222, in nidium those are totally incorrect (and seemingly randomly), too. Violations from previously mentioned numbers to wrong ASCII charset and others is the case in nidium.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions