Check for CapsLock ON in “onfocus” event

前端 未结 3 1366
时光说笑
时光说笑 2021-01-21 01:45

My following code for checking whether Capslock is on or not works fine on \"onkeypress\" event.

But i want it for \"onfocus\" event. i tried replacing \"onkeypress\" w

3条回答
  •  醉酒成梦
    2021-01-21 02:00

    There is a jQuery plugin called capslockstate which will keep track of the state of the caps lock key, allowing you to use that information as and when needed.

    It will monitor the state for the entire page, and then you can retrieve the state when the desired element gains focus.

    It's also based on watching key presses, but not limited to lower ASCII characters and handles situations like the Caps Lock key itself being pressed.

    Your situation would become something like:

    
    
    
    
    
    
    

    Note that I've only jQueryified the essential bits, more could still be done.

提交回复
热议问题