How to find the key code for a specific key

后端 未结 11 2099
猫巷女王i
猫巷女王i 2020-12-28 09:29

What\'s the easiest way to find the keycode for a specific key press?

Are there any good online tools that just capture any key event and show the code?

I wa

11条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-28 10:11

    If you are looking for an online tool, https://keyjs.dev is probably the best option available:

    • By default, it displays e.key, e.code, e.which and e.keyCode for the keydown event.

    • If you need more than that, you can expand it and you will get a table with more properties for keydown, keypress and keyup.

    • If you still need more than that, open DevTools and you will see all the keys you press are logged to the console in a table-like style. Just click the row you are interested in to expand it and see the whole event object.

    Disclaimer: I'm the author.

提交回复
热议问题