用户按下HTML键时执行脚本?
使用onkeydown 属性。当用户按下按键时,onkeydown属性将触发。
示例
您可以尝试运行以下代码来在按下键时执行脚本-
<!DOCTYPE html>
<html>
<body>
<p>Press a key inside the textbox.</p>
<input type = "text" onkeydown = "display()">
<script>
function display() {
alert("您按下了一个键!");
}
</script>
</body>
</html>热门推荐
10 朋友买新房祝福语简短
11 夏天客户祝福语大全 简短
12 节日祝福语简短中秋暧昧
13 医美的祝福语大全简短
14 生日祝福语男生韩语简短
15 生日祝福语 男性简短独特
16 当伴娘祝福语简短大方
17 高考成绩出祝福语 简短
18 简短的爱情生日祝福语