Edit The Code:
See Result »
Try it Yourself - ©
w3big.com
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>本教程(w3big.com)</title> <script> function myFunction(){ alert("你在输入框内按下一个按键"); } </script> </head> <body> <p>当用户在输入框内按下一个按键时函数被触发</p> <input type="text" onkeypress="myFunction()"> </body> </html>