KeyCode 查找器
按任意键查看其 JavaScript 事件属性,包括 key、code、keyCode 和修饰键状态。
Press any key to see its codes
Click anywhere on the page and press a key
Note:
keyCode and which are deprecated. Use key for character and code for physical key.Keyboard Events - 技术详情
Modern browsers use event.key (character) and event.code (physical key). The legacy keyCode property is deprecated but still widely used for compatibility.
命令行替代方案
// JavaScript keyboard event listener
document.addEventListener('keydown', (e) => {
console.log('key:', e.key);
console.log('code:', e.code);
console.log('keyCode:', e.keyCode);
});