键盘监听事件

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
			document.onkeydown = keydown;
			function keydown(){
				var keycode = event.keyCode;
				if(keycode==81){
					alert("哈撒k");
				}else if(keycode==82){
					alert("一库");
				}else if(keycode==69){
					alert("陀螺转");
				}else if(keycode==87){
					alert("面对疾风吧");
				}
				
			}
		</script>
	</head>
	<body>
	</body>
</html>

猜你喜欢

转载自blog.csdn.net/gadxiong/article/details/80248699