Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | DOM KeyboardEvent shiftKey Property

Improve Article
Save Article
  • Last Updated : 06 Jul, 2022
Improve Article
Save Article

The KeyboardEvent shiftKey property in HTML DOM is a read-only property and used to return a Boolean value which indicates the SHIFT key is pressed or not. The KeyboardEvent shiftKey property returns true if the SHIFT key is pressed, otherwise returns false. 



Below program illustrates the KeyboardEvent shiftkey Property in HTML DOM: 

Example: This example check whether the SHIFT key is pressed or not. 


<!DOCTYPE html>
        HTML DOM KeyboardEvent shiftKey Property
    <h2>KeyboardEvent shiftKey Property</h2>
        Check whether the SHIFT key is pressed or not
    <input type="text" onkeydown="keyboard(event)">
    <p id="test"></p>
    <!-- script to check shift key is pressed or not -->
        function keyboard(event) {
            var a = document.getElementById("test");
            if (event.shiftKey) {
                a.innerHTML = "The Shift key has been pressed!";
            else {
                a.innerHTML = "The Shift key has not been pressed!";


Before Press the key:


After Press the key:


Supported Browsers: The browser supported by KeyboardEvent shiftKey Property are listed below:

  • Opera 12.1
  • Internet Explorer 9
  • Google Chrome 1
  • Edge 12
  • Firefox 1.5
  • Apple Safari 1.2

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!