小小的demo,用js捕捉键盘盘上按下了那个键,然后展示出对应的code值

<!DOCTYPE html>
<html>
<head>
<script>
function showKeyCode(event)
{
document.getElementById("result").value= event.keyCode;
}
 
</script>
</head>
 
<body onkeyup="showKeyCode(event)">
<p>按下键盘上的键,文本框中会显示对应的code</p>
<input type="text" id="result" value="1" />
</body>
 
</html>

以上所述就是本文的全部内容了,希望大家能够喜欢。

点赞(193)

评论列表共有 0 条评论

立即
投稿
返回
顶部