 <p>In jQuery,</p> <pre><code>$('#example').keypress(function(e) { var s = String.fromCharCode( e.which ); if ( s.toUpperCase() === s &amp;&amp; s.toLowerCase() !== s &amp;&amp; !e.shiftKey ) { alert('caps is on'); } }); </code></pre> <p>Avoid the mistake, like the backspace key, s.toLowerCase() !== s is needed.</p> <p><strong>You have try this code?</strong></p> <pre><code>function isCapslock(e){ e = (e) ? e : window.event; var charCode = false; if (e.which) { charCode = e.which; } else if (e.keyCode) { charCode = e.keyCode; } var shifton = false; if (e.shiftKey) { shifton = e.shiftKey; } else if (e.modifiers) { shifton = !!(e.modifiers &amp; 4); } if (charCode &gt;= 97 &amp;&amp; charCode &lt;= 122 &amp;&amp; shifton) { return true; } if (charCode &gt;= 65 &amp;&amp; charCode &lt;= 90 &amp;&amp; !shifton) { return true; } return false; } </code></pre>