Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cookiengineer opened this issue Jan 27, 2018 · 1 comment
Open

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

cookiengineer opened this issue Jan 27, 2018 · 1 comment

Comments

@cookiengineer
Copy link
Contributor

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.

@cookiengineer
Copy link
Contributor Author

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

};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant