Restrict Shift Key using jQuery
$(document).ready(function(){ $("#txtNumbers").keydown(function(event) { if(event.shiftKey) { alert('You have pressed Shift Key.'); event.preventDefault(); } }); });
Above code uses keydown event to track shift key, if you use same method in keyPress event, then it will not work. The difference between keydown() and keypress() is that if the user repeats any key by pressing and holding a key, the keydown() event is executed only once whereas the keypress() event isexecuted for each inserted character. Also, the modifier keys Shift, Ctrl, etc. are recognized by keydown(), but keypress() is not fired by these modifier keys.
Read my other post that allows only number
Feel free to contact me for any help related to jQuery, I will gladly help you.