1、JavaScript 方法:
[javascript] <script> <BR>document.onkeydown=function(event){ <BR>e = event ? event :(window.event ? window.event : null); <BR>if(e.keyCode==13){ <BR>//执行的方法 <BR>alert('回车检测到了'); <BR>} <BR>} <BR></script>
<script> <BR>document.onkeydown=function(event){ <BR>e = event ? event :(window.event ? window.event : null); <BR>if(e.keyCode==13){ <BR>//执行的方法 <BR>alert('回车检测到了'); <BR>} <BR>} <BR></script>
2、jQuery 方法:
[javascript] <script> <BR>$(document).ready(function(){ <BR>$("按下回车的控件").keydown(function(e){ <BR>var curKey = e.which; <BR>if(curKey == 13){ <BR>$("#回车事件按钮控件").click(); <BR>return false; <BR>} <BR>}); <BR>}); <BR></script>