运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>Keyboard Events</h1> <h2>The metaKey Property</h2> <p>Press a key on the keyboard in the input field to find out if the META key was pressed.</p> <input type="text" onkeydown="isKeyPressed(event)"> <p id="demo"></p> <script> function isKeyPressed(event) { const 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>