HTML DOM KeyboardEvent getModifierState() Method Last Updated : 03 Oct, 2024 Comments Improve Suggest changes Like Article Like Report The KeyboardEvent getModifierState() method in HTML DOM is used to return whether a specified modifier key is pressed, or activated. The KeyboardEvent getModifierState() method returns true if the specified key is pressed, otherwise it returns false. The list of key which is pressed then Modifier keys activated are given below: AltAltGraphControlMetaShiftModifier keys are activated when the user clicks and deactivated by using clicked once again: CapsLockNumLockScrollLockSyntax:event.getModifierState( modifierKey )Example: In this example, find whether or not the "SHIFT" key is being pressed down. html <!DOCTYPE html> <html> <head> <title> HTML DOM KeyboardEvent getModifierState() Method </title> </head> <body> <h2> KeyboardEvent getModifierState() Method </h2> <p> Check whether the SHIFT key pressed down or not </p> <input type="text" size="20" onkeydown="keyboard(event)"> <p id="test"></p> <script> function keyboard(event) { let s = event.getModifierState("Shift"); document.getElementById("test").innerHTML = "Is SHIFT being pressed: " + s; } </script> </body> </html> Output:is shift key pressed?Supported Browsers: The browser supported by KeyboardEvent getModifierState() Method are listed below: Google Chrome 30.0Firefox 15.0Safari 10.1Opera 17.0 Comment More infoAdvertise with us Next Article HTML DOM KeyboardEvent getModifierState() Method S Shubrodeep Banerjee Follow Improve Article Tags : Web Technologies HTML HTML-DOM HTML-Methods Similar Reads HTML DOM Location host Property The Location Host property in HTML is used to sets or return the hostname and port of a URL. The Location Hash property doesn't return the port number if it is not specified in the URL. Syntax: It returns the host property. location.hostIt is used to set the host property. location.host = hostname:p 1 min read HTML DOM Location protocol Property The Location protocol property in HTML is used to return the protocol or set the protocol of the current URL. It returns a string that contains the protocol of the current URL, including the colon (:). Syntax: It returns the protocol property. location.protocolIt is used to set the protocol property 1 min read HTML DOM Location pathname Property The Location pathname property in HTML is used to set or return the pathname of a URL. The Location pathname property returns a string that represents the pathname of the URL. Syntax: It returns the pathname property.location.pathnameIt is used to set the pathname property.location.pathname = pathEx 1 min read HTML DOM Location hostname Property The Location hostname property in HTML is used to return the hostname of the current URL. The Location hostname property returns a string that contains the domain name, or the IP address of a URL. Syntax: It returns the hostname property. location.hostname It is used to set the hostname property. lo 1 min read HTML DOM Location href Property The Location href property in HTML is used to set or return the complete URL of the current page. The Location href property can also be used to set the href value point to another website or point to an email address. The Location href property returns a string that contains the entire URL of the p 2 min read HTML | DOM Input Image Object The Input Image Object in HTML DOM is used to represent the HTML < input > element with type=âimageâ. This tag is used to access or create the element. This element can be accessed by using getElementById() method. Syntax: document.getElementById("MyImage"); Return Value: It return the propert 3 min read HTML | DOM Ol start Property The DOM Ol start property is used to set or return the value of the start attribute in an ordered list. The start attribute in HTML is used to specify the start value for numbering the individual list item. It is used with an ordered list. Syntax: It is used to return the start property. olObject.st 2 min read HTML | DOM Option disabled Property The DOM Option disabled Property is used to set or return whether the value of an option would be disabled or not. The disabled attribute for the element in HTML is used to specify that the option value is disabled. A disabled option is un-clickable and unusable. It is a boolean attribute. Syntax: I 2 min read HTML | DOM KeyboardEvent keyCode Property The KeyboardEvent keyCode property is used for returning the Unicode character code of the key that has been used to trigger an onkeypress event. The KeyboardEvent keyCode property is also used for returning the Unicode character code of a key that has triggered an onkeydown or onkeyup event. The ke 2 min read HTML DOM InputEvent The input event is fired when the user changes an element, the value of an element or <textarea> element. DOM InputEvent occurs when an element in the HTML document gets input from the user. InputEvent property: data: Returns the inserted characters.dataTransfer: Returns an object containing i 2 min read Like