JS的捕捉回车键

回车键的键值:13
Esc的键值:27
	<!DOCTYPE html>
	<html>
		<head>
			<meta charset="utf-8">
			<title></title>
		</head>
		<body>
			<input type="text" id="username"/>
			<script type="text/javascript"">
				window.onload=function(){
					document.getElementById("username").onkeydown=function(event){
						if(event.keyCode===13){
							alert('正在进行验证...')
						}
					}
				}
			</script>
		</body>
	</html>

  

原文地址:https://www.cnblogs.com/-slz-2/p/15546024.html