Skip to content

Instantly share code, notes, and snippets.

@stellartux
Last active April 4, 2022 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stellartux/6968e5aa8dd54bd6ab3fb91b7550ae9d to your computer and use it in GitHub Desktop.
Save stellartux/6968e5aa8dd54bd6ab3fb91b7550ae9d to your computer and use it in GitHub Desktop.
Boilerplate JSON for remapping JS keycodes
{
"Backspace": 0,
"Tab": 0,
"Enter": 0,
"ShiftLeft": 0,
"ShiftRight": 0,
"ControlLeft": 0,
"ControlRight": 0,
"AltLeft": 0,
"AltRight": 0,
"Pause": 0,
"CapsLock": 0,
"Escape": 0,
"Space": 0,
"PageUp": 0,
"PageDown": 0,
"End": 0,
"Home": 0,
"ArrowLeft": 0,
"ArrowUp": 0,
"ArrowRight": 0,
"ArrowDown": 0,
"PrintScreen": 0,
"Insert": 0,
"Delete": 0,
"Digit0": 0,
"Digit1": 0,
"Digit2": 0,
"Digit3": 0,
"Digit4": 0,
"Digit5": 0,
"Digit6": 0,
"Digit7": 0,
"Digit8": 0,
"Digit9": 0,
"KeyA": 0,
"KeyB": 0,
"KeyC": 0,
"KeyD": 0,
"KeyE": 0,
"KeyF": 0,
"KeyG": 0,
"KeyH": 0,
"KeyI": 0,
"KeyJ": 0,
"KeyK": 0,
"KeyL": 0,
"KeyM": 0,
"KeyN": 0,
"KeyO": 0,
"KeyP": 0,
"KeyQ": 0,
"KeyR": 0,
"KeyS": 0,
"KeyT": 0,
"KeyU": 0,
"KeyV": 0,
"KeyW": 0,
"KeyX": 0,
"KeyY": 0,
"KeyZ": 0,
"MetaLeft": 0,
"MetaRight": 0,
"ContextMenu": 0,
"Numpad0": 0,
"Numpad1": 0,
"Numpad2": 0,
"Numpad3": 0,
"Numpad4": 0,
"Numpad5": 0,
"Numpad6": 0,
"Numpad7": 0,
"Numpad8": 0,
"Numpad9": 0,
"NumpadMultiply": 0,
"NumpadAdd": 0,
"NumpadSubtract": 0,
"NumpadDecimal": 0,
"NumpadDivide": 0,
"F1": 0,
"F2": 0,
"F3": 0,
"F4": 0,
"F5": 0,
"F6": 0,
"F7": 0,
"F8": 0,
"F9": 0,
"F10": 0,
"F11": 0,
"F12": 0,
"NumLock": 0,
"ScrollLock": 0,
"Semicolon": 0,
"Equal": 0,
"Comma": 0,
"Minus": 0,
"Period": 0,
"Slash": 0,
"Backquote": 0,
"BracketLeft": 0,
"Backslash": 0,
"BracketRight": 0,
"Quote": 0
}
{
"Digit0": 75,
"Digit2": 61,
"Digit3": 63,
"Digit5": 66,
"Digit6": 68,
"Digit7": 70,
"Digit9": 73,
"KeyB": 55,
"KeyC": 52,
"KeyD": 51,
"KeyE": 64,
"KeyG": 54,
"KeyH": 56,
"KeyI": 72,
"KeyJ": 58,
"KeyL": 61,
"KeyM": 59,
"KeyN": 57,
"KeyO": 74,
"KeyP": 76,
"KeyQ": 60,
"KeyR": 65,
"KeyS": 49,
"KeyT": 67,
"KeyU": 71,
"KeyV": 53,
"KeyW": 62,
"KeyX": 50,
"KeyY": 69,
"KeyZ": 48,
"Semicolon": 63,
"Equal": 78,
"Comma": 60,
"Period": 62,
"Slash": 64,
"BracketLeft": 77,
"Backslash": 47,
"BracketRight": 79
}
@stellartux
Copy link
Author

Keys are event.code values, key positions are those of QWERTY layout, regardless of OS's keyboard layout. Use event.key values to access the codepoint of a given key, rather than a position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment