FormsLesson 141Free preview
Detect Caps Lock
This lesson is part of How To · All levels
Summary
Detect Caps Lock is a feature to alert when a user is typing with Caps Lock active, especially on a password column. JavaScript checks the status of the button using the getModifierState method on the event keyboard. Warnings should be helpful, not blocking users.
Key points
- The event keyboard provides getModifierState("CapsLock").
- Check the status on the keydown or key when the user types.
- Display warnings near the password column, not as a disturbing alert.
- Hide the warning when the Caps Lock is off.
- This detection is not always accurate on a virtual keyboard or a specific device.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.