Wednesday 31 March 2021

How to detect Caps Lock is ON on web browser on Android Devices using JavaScript?

We can very well detect CapsLock is ON/not on iPhone web browser using KeyboardEvent.getModifierState(), with sample code,

function checkCapsLock(e) {
  if (e.getModifierState("CapsLock")) {
    alert("Caps ON");
  }
}

But it doesn't work on a browser on Android Devices. I've tried many other solutions using charCode, keyCode, shiftKey, which, etc. methods on the event with listeners like keyup, keydown, keypress, etc. But no luck.

I've gone through the answers mentioned on stackoverflow, and other links too. But still no luck.

Is there any workaround for this?

PS: This is not a duplicate question, I'm asking about the issue on the Android web browser!

EDIT: On W3C, we can observe that CapsLock can be detected on Web or mobile web browser on iPhone, but not on a web browser on Android devices.



from How to detect Caps Lock is ON on web browser on Android Devices using JavaScript?

No comments:

Post a Comment