Get key value of a key pressed

后端 未结 8 2140
别那么骄傲
别那么骄傲 2021-01-05 01:14

I don\'t find how to get the value of a key pressed. I currently have

$(\'#info_price\').bind(\'keydown\',function(evt){
    alert(evt.keyCode);
         


        
8条回答
  •  一生所求
    2021-01-05 01:19

    The key code does not directly map to the character value. Instead, you need to look at the keypress event, which provides you with a charCode property. You can then use String.fromCharCode to turn that into a string.

提交回复
热议问题