JavaScript: Detecting Caps lock

I wanted to see if you could detect caps lock in JavaScript. Why? As a small usability touch, basically alerting users that caps lock is enabled when they are entering passwords for example. I’ve wrapped up the logic in a simple function that can help you detect caps lock on a key press.

 

Share this Listing