Javascript examples for DOM Event:Element Event Attribute
The onkeydown event occurs when the user is pressing 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"> <script> document.getElementById("demo").onkeydown = function() {myFunction()}; function myFunction() {//from ww w . j a va2 s . c o m document.getElementById("demo").style.backgroundColor = "red"; } </script> </body> </html>