W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>在输入字段中按键盘上的某个键。</p> <input type="text" size="40" onkeydown="myFunction(event)"> <p id="demo"></p> <script> function myFunction(event) { var x = event.key; document.getElementById("demo").innerHTML = "The pressed key was: " + x; } </script> </body> </html>