检测键盘的 CAPS LOCK 开关


function  detectCapsLock(e,divid){
   valueCapsLock  =  e.keyCode ? e.keyCode:e.which; // Caps Lock is on? 
   valueShift  =  e.shiftKey ? e.shiftKey:((valueCapsLock  ==   16 ) ? true : false ); // shift is press?
    if (((valueCapsLock >=   65   &&  valueCapsLock  <=   90 )  &&   ! valueShift) // Caps Lock is on and  shift not press 
    || ((valueCapsLock >=   97   &&  valueCapsLock  <=   122 )  &&  valueShift)) // Caps Lock is on and shift is press 
       document.getElementById(divid).style.display  =  'block';
    else 
       document.getElementById(divid).style.display  =  'none';
}

你可能感兴趣的:(Lock)