KeyboardEvent.keyCode deprecated. What does this mean in practice?

前端 未结 6 1108
甜味超标
甜味超标 2020-12-23 02:36

According to MDN, we should most definitely not be using the .keyCode property. It is deprecated:

https://developer.mozilla.org/en-US/do

6条回答
  •  春和景丽
    2020-12-23 03:27

    For instance if you want to detect whether the "Enter"-key was clicked or not:

    Instead of

    event.keyCode === 13
    

    Do it like

    event.key === 'Enter'
    

提交回复
热议问题