<input type="password" id="password">
<span id="warning" style="display:none;color:#c00">[Caps Lock]</span>
<script>
document.getElementById("password").addEventListener("keyup", function(event) {
document.getElementById("warning").style.display = (event.getModifierState("CapsLock")) ? "inline" : "none";
});
</script>
Forgot how much it annoys me when applications don’t show the same visual cue when you click or tab into the field…
Demo: https://jsfiddle.net/j3k2ma16/
Shorthand way to cover all 3 events outlined above…
Demo: https://jsfiddle.net/2yns13rq/2/