wasm: Arrange key codes in numberical order of value

This commit is contained in:
Ali Chraghi 2022-06-25 17:11:59 +04:30 committed by Stephen Gutekanst
parent 1b32552e73
commit c831840094

View file

@ -3,7 +3,6 @@ const text_decoder = new TextDecoder();
const text_encoder = new TextEncoder();
let log_buf = "";
// TODO: Arrange in numberical order of value
function convertKeyCode(code) {
const mapKeyCode = {
KeyA: 0,
@ -42,65 +41,6 @@ function convertKeyCode(code) {
Digit7: 33,
Digit8: 34,
Digit9: 35,
Enter: 78,
Escape: 79,
Backspace: 105,
Tab: 80,
Space: 106,
Minus: 107,
Equal: 108,
BracketLeft: 109,
BracketRight: 110,
Backslash: 111,
ShiftLeft: 81,
ShiftRight: 82,
ControlLeft: 83,
ControlRight: 84,
AltLeft: 85,
AltRight: 86,
OSLeft: 87,
MetaLeft: 87,
OSRight: 88,
MetaRight: 88,
Semicolon: 112,
Quote: 113,
Backquote: 117,
ContextMenu: 89,
Comma: 114,
Period: 115,
Slash: 116,
CapsLock: 91,
PrintScreen: 92,
ScrollLock: 93,
Pause: 94,
Insert: 100,
Home: 96,
PageUp: 98,
Delete: 95,
End: 97,
PageDown: 99,
ArrowRight: 102,
ArrowLeft: 101,
ArrowDown: 104,
ArrowUp: 103,
NumLock: 90,
NumpadDivide: 61,
NumpadMultiply: 62,
NumpadSubtract: 63,
NumpadAdd: 64,
Numpad1: 66,
Numpad2: 67,
Numpad3: 68,
Numpad4: 69,
Numpad5: 70,
Numpad6: 71,
Numpad7: 72,
Numpad8: 73,
Numpad9: 74,
Numpad0: 65,
NumpadDecimal: 75,
NumpadEqual: 76,
NumpadEnter: 77,
F1: 36,
F2: 37,
F3: 38,
@ -126,6 +66,65 @@ function convertKeyCode(code) {
F23: 58,
F24: 59,
F25: 60,
NumpadDivide: 61,
NumpadMultiply: 62,
NumpadSubtract: 63,
NumpadAdd: 64,
Numpad0: 65,
Numpad1: 66,
Numpad2: 67,
Numpad3: 68,
Numpad4: 69,
Numpad5: 70,
Numpad6: 71,
Numpad7: 72,
Numpad8: 73,
Numpad9: 74,
NumpadDecimal: 75,
NumpadEqual: 76,
NumpadEnter: 77,
Enter: 78,
Escape: 79,
Tab: 80,
ShiftLeft: 81,
ShiftRight: 82,
ControlLeft: 83,
ControlRight: 84,
AltLeft: 85,
AltRight: 86,
OSLeft: 87,
MetaLeft: 87,
OSRight: 88,
MetaRight: 88,
ContextMenu: 89,
NumLock: 90,
CapsLock: 91,
PrintScreen: 92,
ScrollLock: 93,
Pause: 94,
Delete: 95,
Home: 96,
End: 97,
PageUp: 98,
PageDown: 99,
Insert: 100,
ArrowLeft: 101,
ArrowRight: 102,
ArrowUp: 103,
ArrowDown: 104,
Backspace: 105,
Space: 106,
Minus: 107,
Equal: 108,
BracketLeft: 109,
BracketRight: 110,
Backslash: 111,
Semicolon: 112,
Quote: 113,
Comma: 114,
Period: 115,
Slash: 116,
Backquote: 117,
};
const k = mapKeyCode[code];