Javascript examples for DOM Event:onkeypress
The onkeypress event occurs when the user presses a key.
Bubbles | Yes |
---|---|
Cancelable | Yes |
Supported HTML tags: | All HTML elements, EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title> |
<!DOCTYPE html> <html> <body> <input type="text" id="demo" onkeypress="myFunction()"> <script> function myFunction() {//from w w w. ja va2 s.com document.getElementById("demo").style.backgroundColor = "red"; } </script> </body> </html>