執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <head> <script> function myFunction() { alert("You pressed a key inside the input field"); } </script> </head> <body> <h1>JavaScript HTML Events</h1> <h2>The onkeypress Attribute</h2> <p>A function is triggered when the user is pressing a key in the input field.</p> <input type="text" onkeypress="myFunction()"> </body> </html>