How to catch event.keyCode and change it to another keyCode?

前端 未结 4 1809
無奈伤痛
無奈伤痛 2020-12-06 10:56

I have checked other questions here at SO, however they do not answer my question. I want to simply catch certain keyCode and replace it with another. I am working with char

4条回答
  •  一整个雨季
    2020-12-06 11:31

    Keyboard event properties are all READ-only. You cannot capture one keyCode and change it to another.

    See reference from MDN - Keyboard Events - All are read only can't be set.

    As you mentioned in your post. -- If you wan't to handle, then you have to stop browser default key press and set the desired value to the element yourself.

提交回复
热议问题