Skip to content
Related Articles

Related Articles

JavaScript | MouseEvent shiftKey Property

Improve Article
Save Article
  • Last Updated : 07 Jan, 2019
Improve Article
Save Article

The mouseEvent shiftKey property is used to define whether the shift key is pressed or not. It is a boolean value. When the shift key is pressed then on click of the mouse left button, it returns true and if the shift key is not pressed then it returns false.



Return Value: It returns a boolean value indicating whether shift key is pressed or not.

  • true: it indicates shift key is pressed.
  • false: it indicates shift key is not pressed.

Example :

<!DOCTYPE html>
        <title>JavaScript Mouse Event</title>
    <body style = "text-align:center;">
        <h1 style = "color:green;">
            mouseEvent shiftKey Property
        <button onclick="geek (event);">Get Shift key state!</button>        
        function geek (event) {
            if (event.shiftKey) {
                alert ("Shift key is pressed.");
            else {
                alert ("Shift key is not pressed.");

Clicking button (Shift key is not pressed):
Clicking button (Shift key is pressed):

Supported Browsers: The browser supported by shiftKey property are listed below:

  • Apple Safari
  • Google Chrome
  • Firefox
  • Opera
  • Internet Explorer
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!