常见的键盘事件
<!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>