四、键盘事件

四、键盘事件

onkeyDown 当键盘按下的时候触发

绑定方式:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 键盘按下
document.onkeydown = function(){
console.log("键盘按下了");
}

// 键盘抬起
document.onkeyup = function(){
console.log("键盘抬起了");
}

// 有字符输入
document.onkeypress = function(){
console.log("有字符输入了");
}

输出结果:

UMRRU0.png

点击查看

本文标题:四、键盘事件

文章作者:Mango

发布时间:2020年07月13日 - 23:14:45

最后更新:2020年07月14日 - 13:27:10

原始链接:https://mango185.github.io/post/4c876ecc.html

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

-------------------本文结束 感谢您的阅读-------------------