Languages
[Edit]
EN

JavaScript - detect when shift key was pressed

0 points
Created by:
a_horse
538

In this article, we would like to show you how to detect when the shift key was pressed using JavaScript​​​​​.

Quick solution:

 

1. Practical example

Edit

In this example, we use shiftKey property to detect if the shift key was pressed.

2. Shift + another key

Edit

In this example, we present how to detect when ArrowUp key was pressed while holding the Shift key.

3. Shift + mouse click

Edit

In this example, we present how to detect when the left mouse button was clicked while holding the Shift key.

See also

Edit
  1. JavaScript - keyboard events

  2. JavaScript - mouse events

References

Edit
  1. KeyboardEvent.shiftKey - Web APIs | MDN
  2. Document: keydown event - Web APIs | MDN

Alternative titles

  1. JavaScript - detect when shift key was pressed with another key
  2. JavaScript - detect when key was pressed while holding shift key
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join