How to detect the state of uppercase keys ( caps lock ) by javascript

58 0

Forget where to experience, the web interface will prompt the user to open the keyboard 's uppercase key ( caps lock ), which can effectively reduce the password input. Someone knows how to test with javascript.

1 Answers

87 0
var capsLockKey = e.keyCode? e.keyCode : e.which;
var shifKey = e.shiftKey? e.shiftKey:((capsLockKey == 16)? true : false);
if(((capsLockKey> = 65 && capsLockKey <= 90) &&!shifKey)||((capsLockKey> = 97 && capsLockKey <= 122) && shifKey)){
 return true;
}else{
 return false;
}
98 0
var capsLockKey = e.keyCode? e.keyCode : e.which;
var shifKey = e.shiftKey? e.shiftKey:((capsLockKey == 16)? true : false);
if(((capsLockKey> = 65 && capsLockKey <= 90) &&!shifKey)||((capsLockKey> = 97 && capsLockKey <= 122) && shifKey)){
 return true;
}else{
 return false;
}
...