HTML DOM onkeydown Event Last Updated : 20 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The DOM onkeydown event in HTML occurs when a key is pressed by the user. Order of events related to the onkeydown event: onkeydownonkeypressonkeyup Supported HTML tags: All HTML elements, EXCEPT: <base><bdo><br><head><html><iframe><meta><param><script><style><title> Syntax: In HTML:<element onkeydown="myScript">>In JavaScript:object.onkeydown = function(){myScript};In JavaScript, using the addEventListener() method:object.addEventListener("keydown", myScript); Example: onkeydown Event using the addEventListener() method html <!DOCTYPE html> <html> <body> <h1 style="color:green"> GeekforGeeks </h1> <p> Press any key inside the input field </p> <input type="text" id="inputField" style="background-color:green"> <script> document.getElementById( "inputField").addEventListener("keydown", GFGFun); function GFGFun() { document.getElementById( "inputField").style.backgroundColor = "yellow"; } </script> </body> </html> Output: Supported Browsers: The browsers supported by HTML DOM onkeydown Event are listed below: Google ChromeInternet ExplorerFirefoxApple SafariOpera Comment More infoAdvertise with us Next Article HTML DOM onkeydown Event V Vijay Sirra Follow Improve Article Tags : Web Technologies HTML Web technologies HTML-DOM Similar Reads HTML DOM onmousedown Event The HTML DOM onmousedown event occurs when a mouse button is pressed over an element. It's useful for implementing interactive features that respond to mouse clicks or taps on web elements. Syntax: In HTML<element onmousedown="myScript"> In JavaScriptobject.onmousedown = function(){myScript}; 1 min read HTML DOM onkeyup Event The HTML DOM onkeyup event in HTML occurs when a key is released after pressing by the user. Order of events related to the onkeyup event. onkeydownonkeypressonkeyup Syntax: In HTML:<element onkeyup="myScript">In JavaScript:object.onkeyup = function(){myScript};In JavaScript, using the addEven 2 min read HTML DOM onkeypress Event The DOM onkeypress event in HTML occurs when a key is pressed by the user. Order of events related to the onkeypress event: onkeydownonkeypressonkeyup Supported HTML tags: All HTML elements, EXCEPT: <base><bdo><br><head><html><iframe><meta><param><s 1 min read HTML onkeydown Event Attribute The onkeydown event attribute works when the user presses any key from the keyboard. The onkeydown event is triggered when the down key is pressed down and used for capturing and responding to key events. Syntax: <element onkeydown = "script">Supported Tags: It supports all HTML elements EXCEP 2 min read HTML DOM onpaste Event The HTML DOM onpaste event occurs when some content is pasted in an element. this event works on every element like in <p> element if contenteditable set is true then we can paste content in <p> element. The HTML DOM onpaste event is mostly used in input element type="text". Supported Ta 1 min read Like