W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>在输入字段中按键盘上的一个键,以确定是否按下了 META 键。</p> <input type="text" onkeydown="isKeyPressed(event)"> <p id="demo"></p> <script> function isKeyPressed(event) { var x = document.getElementById("demo"); if (event.metaKey) { x.innerHTML = "The META key was pressed!"; } else { x.innerHTML = "The META key was NOT pressed!"; } } </script> </body> </html>