Check for CapsLock ON in “onfocus” event

前端 未结 3 1343
时光说笑
时光说笑 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 01:48

    Unfortunately not - the keyCode property of the event object is only sent on key-based events (for obvious reasons), which is why it wouldn't work onfocus, onclick etc.

    There aren't any other JavaScript ways of doing it - although there is a potential solution if you use flash - but that seems somewhat overkill for your requirements...

提交回复
热议问题