HTML DOM KeyboardEvent code Property Last Updated : 13 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The keyboardEvent code property in HTML represents a physical key on the keyboard. It is used to return the key that triggers the event. Syntax: event.code Return Value: It returns a string that represents which key is pressed. Example 1: With KeyDown Event HTML <html> <head> <title>DOM keyboardEvent code Property</title> </head> <body style="text-align: center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h2> DOM keyboardEvent code Property </h2> Input: <input type="text" placeholder="Press any key.."> <p id="p"></p> <script> // Adding a event listener function window.addEventListener("keydown", function (event) { let code = "keydown code = '" + event.code + "'" + "<br/>"; // Creating a span element let element = document.createElement("span"); element.innerHTML = code; // Appending the created element to paragraph document.getElementById("p").appendChild(element); }, true); </script> </body> </html> Output: Example 2: With KeyPress Event HTML <html> <head> <title>DOM keyboardEvent code Property</title> </head> <body style="text-align: center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h2> DOM keyboardEvent code Property </h2> Input: <input type="text" placeholder="Press any key.."> <p id="p"></p> <script> // Adding a event listener function window.addEventListener("keypress", function (event) { let code = "keypress code = '" + event.code + "'" + "<br/>"; // Creating a span element let element = document.createElement("span"); element.innerHTML = code; // Appending the created element to paragraph document.getElementById("p").appendChild(element); }, true); </script> </body> </html> Output: Example 3: With KeyUp Event HTML <html> <head> <title>DOM keyboardEvent code Property</title> </head> <body style="text-align: center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h2> DOM keyboardEvent code Property </h2> Input: <input type="text" placeholder="Press any key.."> <p id="p"></p> <script> // Adding a event listener function window.addEventListener("keyup", function (event) { let code = "keyup code = '" + event.code + "'" + "<br/>"; // Creating a span element let element = document.createElement("span"); element.innerHTML = code; // Appending the created element to paragraph document.getElementById("p").appendChild(element); }, true); </script> </body> </html> Output: Supported Browsers: The browser supported by keyboardEvent code property are listed below: Apple Safari 10.1Google Chrome 48.0Edge 79.0Firefox 38.0Opera 35.0Internet Explorer Not supported Comment More infoAdvertise with us Next Article HTML DOM Caption Object V Vishal Chaudhary 2 Follow Improve Article Tags : Web Technologies HTML Web technologies HTML-DOM HTML-Property +1 More Similar Reads HTML DOM Cite Object The DOM Cite Object is used to represent HTML <Cite> element. The Cite element is accessed by getElementById(). Syntax: document.getElementById("id"); Where "id" is the ID assigned to the cite tag. Example 1: In this example, we will use DOM Cite Object HTML <!DOCTYPE html> <html> 1 min read HTML DOM Code Object The DOM Code Object is used to represent the HTML <code> element. The Code element is accessed by getElementById(). Syntax: document.getElementById("id"); Where 'id' is the ID assigned to the code tag. Example 1: In this example, we will use DOM Code Object HTML <!DOCTYPE html> <html 1 min read HTML DOM fullscreenEnabled() Method The fullscreenEnabled() method in HTML DOM is used to check whether the document can be viewed in full-screen mode or not. It returns a single read-only Boolean value. This method may require specific prefixes to work with different browsers. Syntax:document.fullscreenEnabled()Parameters: This metho 2 min read HTML DOM Caption Object The DOM Caption Object is used to represent the HTML <Caption> element (A caption element is used to specify the caption of a table). The Caption element is accessed by getElementById(). Properties: It has a align Attribute which is used to set or return the alignment of the caption. Syntax: d 2 min read HTML DOM Canvas Object The DOM Canvas Object is used to represent the HTML <Canvas> element. The <canvas> tag is used to draw graphics in the document using javascript. It is new in HTML5. The canvas element is accessed by getElementById(). Syntax: accessed by getElementById("id"). Where âidâ is the ID assigne 2 min read HTML DOM importNode() Method The HTML | DOM importNode() Method creates a copy of a node from another document and imports it to the current document. Syntax: document.importNode(externalNode, [deep]) Parameters: externalNode: Node which we need to import from another document, it can be of any type.[deep]: We can set its val 2 min read HTML DOM inputEncoding Property The inputEncoding property returns the character encoding used for parsing the document. This property doesn't have any default value. Syntax:document.inputEncodingParameters:The HTML DOM inputEncoding property does not require any parameter.Return Value:The HTML DOM inputEncoding property returns a 2 min read HTML DOM normalizeDocument() Method The normalizeDocument() method in HTML is used to normalize an HTML document by remove any empty text nodes if exists. After removing the empty nodes, it also merges all of the adjacent nodes present in the document. For Example, consider the below element: Element Geeks Text node: "" Text node: "He 2 min read HTML DOM lang Property In HTML document, the lang property is used to set or return the value of the lang attribute of an element. This attribute specifies the language code of the element's content. The element attribute takes "en" for English, "ja" for Japanese, "es" for Spanish, and so on. The default value of this att 2 min read HTML DOM KeyboardEvent key Property The keyboardEvent key property in HTML is used to return the value of the key pressed when a key event occurs. It returns a single-character or multi-character string depending on which key is pressed. It is a read-only property. Syntax: event.key Return Value: It returns a string that represents th 1 min read Like