How to know if .keyup() is a character key (jQuery)

前端 未结 7 703
遇见更好的自我
遇见更好的自我 2020-11-29 18:57

How to know if .keyup() is a character key (jQuery)

$(\"input\").keyup(function() {

if (key is a character) { //such as a b A b c 5 3 2 $ # ^ ! ^ * # ...etc         


        
相关标签:
7条回答
  • 2020-11-29 19:46

    If you only need to exclude out enter, escape and spacebar keys, you can do the following:

    $("#text1").keyup(function(event) {
    if (event.keyCode != '13' && event.keyCode != '27' && event.keyCode != '32') {
         alert('test');
       }
    });
    

    See it actions here.

    You can refer to the complete list of keycode here for your further modification.

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