generated at
key2keyCode
keyCodeKeyboardEvent.keyとの対応表
script.js
const range = (i, j) => [...Array(j + 1).keys()].slice(i, j + 1); export const KEYCODE_MAP = { Backspace:8, Tab: 9, Enter: 13, Delete: 46, Escape: 27, ' ': 32, PageUp: 33, PageDown: 34, End: 35, Home: 36, ArrowLeft: 37, ArrowUp: 38, ArrowRight: 39, ArrowDown: 40, // alphabets ...Object.fromEntries( range('a'.charCodeAt(0), 'z'.charCodeAt(0)) .flatMap((code, i) => [ [String.fromCodePoint(code), 65 + i], [String.fromCodePoint(code).toUpperCase(), 65 + i], ]) ), // number ...Object.fromEntries([...Array(10).keys()].map(i => [i, i + 48])), // function keys ...Object.fromEntries(range(1, 12).map(i => [`F${i}`, 112 + i])), // 記号 ':': 186, '*': 186, ';': 187, '+': 187, '-': 189, '=': 189, '.': 190, '>': 190, '/': 191, '?': 191, '@': 192, '`': 192, '[': 219, '{': 219, '\\': 220, '|': 220, ']': 221, '}': 221, '^': 222, '~': 222, '_': 226, // Shiftなしの226は\で、\と区別がつかない };

値の確認
js
(async () => { const {KEYCODE_MAP} = await import('/api/code/takker/key2keyCode/script.js'); console.log(KEYCODE_MAP) })();

References

#2021-03-14 20:18:08