javascript实现捕捉键盘上按下的键
小小的demo,用js捕捉键盘盘上按下了那个键,然后展示出对应的code值
<!DOCTYPEhtml>
<html>
<head>
<script>
functionshowKeyCode(event)
{
document.getElementById("result").value=event.keyCode;
}
</script>
</head>
<bodyonkeyup="showKeyCode(event)">
<p>按下键盘上的键,文本框中会显示对应的code</p>
<inputtype="text"id="result"value="1"/>
</body>
</html>
以上所述就是本文的全部内容了,希望大家能够喜欢。