I am trying to find keycode for ampersand and underscore. I should not allow my users to enter ampersands and underscores. I looked at one list and it mentions 55 as the key code for 7 and ampersands, and the other list says 55 is the key code for 7. Therefore, if I return false when my user types 55, I deny the user can use 7, which is not a requirement. How to find keycodes for ampersand and underline?
I just tried with 55, but that only gives me a warning for 7 not with ampersand!
function noenter(e)
{
evt = e || window.event;
var keyPressed = evt.which || evt.keyCode;
if(keyPressed==13)
{
return false;
}
else if(evt.shiftKey && keyPressed===55)
{
alert("no special characters");
return false;
}
}
source
share