keyevent.htm
来自「这是一些关于JavaScript的学习资料 希望对大家有用」· HTM 代码 · 共 45 行
HTM
45 行
<html>
<head>
<title>Listing 9.7. Getting Specific Key Values - 品络科技 pinluo.com</TITLE>
</head>
<body>
<form>
<b>Click inside this text box and press a key.<br>
The key pressed appears in the status bar.</b>
<br>
<input
type="text"
onKeyPress="return keypress_handler(event)">
</form>
<script language="JavaScript" type="text/javascript">
<!--
function keypress_handler(key_event) {
if (document.all) {
//Probably Internet Explorer 4 and later
status = String.fromCharCode(event.keyCode)
return true
}
else if (document.getElementById) {
// Probably Netscape 6 and later
status = String.fromCharCode(key_event.which)
return true
}
else if (document.layers) {
// Probably Netscape 4
status = String.fromCharCode(key_event.which)
return true
}
}
//-->
</script>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?