常见的键盘事件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // keyup 鼠标弹起事件
        document.onkeyup = function() {
            console.log(1111);
        }
        // keydown鼠标按下事件
 
        document.onkeydown = function() {
            console.log(3333);//一直按着就会一直触发这个事件
        }
 
 
        document.onkeypress = function() {//不能识别功能键,
            console.log(444);
        }
 
        // keypress鼠标按下事件
    </script>
</body>
</html>

  

posted @   洛飞  阅读(35)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
点击右上角即可分享
微信分享提示