a11y.skipToMainContent
1

键码信息

按下任意一个键来查看其所有的 JavaScript 键盘事件属性: 密钥,代码, 密钥Code, charCode等.

Click here and press any key…
Was this tool helpful?
Send output to:
Advertisement

How to use Keycode Info

  1. 单击输入区域(或刚开始按键).
  2. 按任意键查看其事件属性 .
  3. 使用您的 JavaScript 代码中的显示值 .

{姓名}是什么来着?

JavaScript键盘事件带有多个属性(键,码,键Code,即CharCode,位置),可以混淆. 此工具会显示您按下的任何密钥的所有属性, 从而容易为您的事件处理器找到正确的值 。

按下任意键——包括修饰键,函数键和特殊字符——以看到事件属性的完整分解. 用于构建键盘快捷键、游戏控制和无障碍功能。

Advertisement

FAQ

钥匙和密码有什么区别?
event.key是生成的字符(如'a'或'A'),而事件。 代码是按下物理键(如"KeyA"). 字符输入使用密钥,物理布局独立快捷键的代码.
关键代码是否贬值?
对 keyCode在 spec中被贬值,但仍得到广泛支持. 对新代码使用密钥或代码.
修饰键有用吗?
对 Shift, Ctrl, Alt, Meta, CapsLock 以及所有其他密钥都得到支持. 该工具还显示修饰状态.

Related tools

Author

MW
Marcus Webb"The DevTool Craftsman"

Full-Stack Developer & Tools Architect

Marcus has been writing code since the dial-up era. He has contributed to open-source developer tools, built CI/CD pipelines for startups, and debugged production incidents at 3 AM more times than he would like to admit. His philosophy is that the best developer tool is the one that gets out of your way, and he writes about practical tooling that helps teams ship faster with fewer headaches.

Advertisement