<input onkeydown="myFunction()"> - Javascript DOM Event

Javascript examples for DOM Event:onkeydown


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>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<input type="text" id="demo" onkeydown="myFunction()">

function myFunction() {//w w w.ja v a  2  s.  c om
    document.getElementById("demo").style.backgroundColor = "red";


Related Tutorials