js检测键盘按键
程序员文章站
2022-05-27 11:06:13
...
js检测键盘按键
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
window.document.onkeydown = keyHandler;
keyHandler();
})
function keyHandler() {
if(event.keyCode == 13) {//回车
alert(1);
}
}
</script>
</head>
<body>
</body>
</html>