<html>
<style>
#text {display:none;color:red}
</style>
<body>
<h3>Detect Caps Lock</h3>
<p>Press the "Caps Lock" key inside the input field to trigger the function.</p>
<input id="myInput" value="Some text..">
<p id="text">WARNING! Caps lock is ON.</p>
<script>
var input = document.getElementById("myInput");
var text = document.getElementById("text");
input.addEventListener("keyup", function(event) {
if (event.getModifierState("CapsLock")) {
text.style.display = "block";
} else {
text.style.display = "none"
}
});
</script>
</body>
<!-- Mirrored from www.w3schools.com/howto/tryit.asp?filename=tryhow_js_detect_capslock by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 02:38:49 GMT -->
</html>