Created
March 13, 2024 15:04
-
-
Save fastfingertips/6010827a7141138bf6886724700e1da0 to your computer and use it in GitHub Desktop.
Detect Caps Lock with JavaScript "w3c.github.io/uievents/#event-modifier-initializers"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelector('input[type=password]').addEventListener('keyup', function (keyboardEvent) { | |
const capsLockOn = keyboardEvent.getModifierState('CapsLock'); | |
if (capsLockOn) { | |
console.log('Caps Lock is ON'); | |
} else { | |
console.log('Caps Lock is OFF'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment