jQuery Event Keypress: Which key was pressed?

后端 未结 24 2118
半阙折子戏
半阙折子戏 2020-11-21 16:48

With jQuery, how do I find out which key was pressed when I bind to the keypress event?

$(\'#searchbox input\').bind(\'keypress\', function(e) {});
         


        
24条回答
  •  时光说笑
    2020-11-21 16:51

    $(document).ready(function(){
        $("#btnSubmit").bind("click",function(){$('#'+'<%=btnUpload.ClientID %>').trigger("click");return false;});
        $("body, input, textarea").keypress(function(e){
            if(e.which==13) $("#btnSubmit").click();
        });
    });
    

    Hope this may help you!!!

提交回复
热议问题