js监听键盘回车

//监听回车

$(document).keydown(function(e) {
   if (e.keyCode == 13) {
   $("#btnLogin").click();
   }
})

//input绑定回车

$('#dataInput').bind('keypress',function(event){
    if(event.keyCode == "13")    
     {
       alert('你输入的内容为:' + $('#dataInput').val());
     }
});
原文地址:https://www.cnblogs.com/shy1766IT/p/4726055.html