aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Detect Caps Lock On or Off in JavaScript

Nov 12, 2014

Here I will explain in
jQuery how to detect caps lock on or off in JavaScript. Generally to detect or check caps lock on or off in page load it’s not possible we can analyze key code only in key press using jQuery or JavaScript.

If you want to detect or check caps loc on or off jQuery  or JavaScript we need to write the code like as shown below

<html xmlns="">
<title>jQuery Check Capsloc on or not in Javascript</title>
<script type="text/javascript">
function checkcapslockon(e) {
var charKeyCode = e.keyCode ? e.keyCode : e.which;
var shiftKey = e.shiftKey ? e.shiftKey : ((charKeyCode == 16) ? true : false);
if (((charKeyCode >= 65 && charKeyCode <= 90) && !shiftKey) || ((charKeyCode >= 97 && charKeyCode <= 122) && shiftKey)) {
alert('Caps Loc On');
else {
alert('Caps Loc Off');
<form id="form1" runat="server">
<b>Enter Text:</b><input type="text" id="txtname" onkeypress="checkcapslockon(event)"/>
Live Demo

To check live demo try to enter text or press Caps Lock button and check status

Enter Text:

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...

Thanks you sir. I have a suggestion i.e, it would be really great if you also explain the code. please add comments.

Anonymous said...


جنید عطاری said...


Anonymous said...


Anonymous said...

Message should be displayed while entering only first letter, not on each letter entry.

Anonymous said...

Good article

Anonymous said...

Not Working(While caps lock on and press any number alert says caps off)

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.