// Get the input field
var input = document.getElementById("myInput");
// Get the warning text
// You can use a div tag also
var text = document.getElementById("text");
// When the user presses any key on the keyboard, run the function
input.addEventListener("keyup", function(event) {
// If "caps lock" is pressed, display the warning text
// You can use ScrollLock or NumLock as well
if (event.getModifierState("CapsLock")) {
text.style.display = "block";
} else {
text.style.display = "none"
}
});