直接放在JSP中的js里面就可以了 $(document).keypress(function(event){ if(event.keyCode==13){ login(); } }); 转载于:https://www.cnblogs.com/phyxis/p/5221070.html