I want to alert to user if CAPS LOCK is ON when HTML page get load.
I have tried search in google and got multiple views from people some are saying possible some are saying not possible.
I have code which will alert to user only when they type something through keyboard.
document.onkeypress = function ( e ) {
e = e || window.event;
var s = String.fromCharCode( e.keyCode || e.which );
if ( s.toUpperCase() === s && !e.shiftKey ) { // incomplete: shift + caps MAY = lowercase
alert('caps is on')
}
}
Working.
Is it possible to alert on load of HTML page?
PS:
Check Scroll Lock, Num Lock & Caps Lock in JavaScript on Page Load
http://dougalmatthews.com/2008/Jul/02/javascript-detecting-caps-lock/