Issue with javascript onkeydown - event.which give characters in upper case only

前端 未结 4 427
北荒
北荒 2021-01-14 04:15

I have written a piece of javascript code to get the key pressed within a text area. I have used the onkeydown event to capture the key pressed and am calling a function whe

4条回答
  •  失恋的感觉
    2021-01-14 04:28

    keydown and keyup don't (mostly) give you characters at all, they give you keycodes. keypress is where you get characters (and if you need to know, also the state of the modifier keys as of when that character was typed, on the event object's ctrlKey, altKey, shiftKey, and metaKey properties). This page goes into the madness that is keyboard events in JavaScript in loving detail...

提交回复
热议问题