Get key value of a key pressed

后端 未结 8 2142
别那么骄傲
别那么骄傲 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:36

    For those who google it now, like I am

    $('input').on('keydown', function(e) {
      console.log(e.key);
    });​
    
    0 讨论(0)
  • 2021-01-05 01:36

    You can detect all key values like this:

    Here is working jsFiddle example.

    $('textarea').keydown(function(e) {
        var order = e.which;
        console.log(order);
    });​
    

    Source.

    0 讨论(0)
提交回复
热议问题