• 常用的键盘事件


    <!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
    </head>

    <body>
        <script>
            // 常用的键盘事件
            //1. keyup 按键弹起的时候触发 
            // document.onkeyup = function() {
            //         console.log('我弹起了');

            //     }
            document.addEventListener('keyup', function() {
                console.log('我弹起了');
            })

            //3. keypress 按键按下的时候触发  不能识别功能键 比如 ctrl shift 左右箭头啊
            document.addEventListener('keypress', function() {
                    console.log('我按下了press');
                })
                //2. keydown 按键按下的时候触发  能识别功能键 比如 ctrl shift 左右箭头啊
            document.addEventListener('keydown', function() {
                    console.log('我按下了down');
                })
                // 4. 三个事件的执行顺序  keydown -- keypress -- keyup
        </script>
    </body>

    </html>
  • 相关阅读:
    BUG记录
    .Net HTTP请求的发送方式与分析
    初始token
    VS2017开发安卓应用(Xamarin)
    路由模板和路由特性
    使用signalR创建聊天室。
    C# SessionHelper
    postgres递归查询所有子部门
    centos7备份postgres
    Centos7挂载硬盘
  • 原文地址:https://www.cnblogs.com/yanlei369343/p/13893940.html
Copyright © 2020-2023  润新知