Caps lock finder for web page
Use this code to find out caps lock on/off. It is easy.
- <html>
- <body>
- <input id=”Txt” type=”text” onkeydown=”KeyDown(event);” onkeyup=”KeyUp(event);” onkeypress=”KeyPress(event);” />
- <script type=”text/javascript”>
- var shiftkey=false;
- function KeyDown(e)
- {
- if(e.keyCode==16)
- shiftkey=true;
- }
- function KeyUp(e)
- {
- if(e.keyCode==16)
- shiftkey=false;
- }
- function KeyPress(e)
- {
- if(((!shiftkey)&&e.keyCode>=65&&e.keyCode<=90)||((shiftkey)&&e.keyCode>=97&&e.keyCode<=122))
- alert(“Caps Lock is on”);
- }
- </script>
- </body>
- </html>
Thank you,
Naga Harish.
Follow me on Twitter Naga harish