分类分类
2015-05-05 15:12作者:zhao
小小的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>
以上所述就是本文的全部内容了,希望大家能够喜欢。
相关