1. JavaScript method :
[javascript] <script> <BR>document.onkeydown=function(event){ <BR>e = event ? event :(window.event ? window.event : null); <BR>if(e.keyCode ==13){ <BR>//Execution method <BR>alert('Carriage return detected'); <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>// Execution method <BR>alert('Carriage return detected'); <BR>} <BR>} <BR></script>
2. jQuery method :
[javascript] <script> <BR> $(document).ready(function(){ <BR>$("Control for pressing Enter").keydown(function(e){ <BR>var curKey = e.which; <BR>if(curKey = = 13){ <BR>$("#Enter event button control").click(); <BR>return false; <BR>} <BR>}); <BR>}); <BR>< /script> <BR></script>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn