Caps lock Detection

Recently I was working on detecting if someone had caps lock on. Rather than try and reinvent the wheel, I looked to see if anyone had created a plugin that did so.

Which as you can guess - someone did. So I looked into and and noticed that it was firing a false positive. When someone had Caps Lock on and hit Shift it was saying that caps lock was off. So I modified the plugin and email it to the original creator.

The creator of the plugin later emailed me back and I think we both learned something very interesting. Turns out on Windows if you have Caps lock on and hit shift it will make the character lowercase, however on a Mac if you have Caps lock on and hit shift it makes the character uppercase.

Which now made things very interesting. What was awesome is someone wrote a plugin which can detect OS & browser and while both the creator and the plugin and I prefer feature detection over OS detection - this is an OS issue. So I ported over the OS detection plugin into the Caps lock plugin and now have a plug in that detect if - Caps lock is on, Caps lock is off, and if the OS is Windows and if Shift is hit if Caps lock is on or if the OS is Mac and if Shift is hit if Caps lock is on.

Edit: Well I sent my code to the plugin’s creator and he caught something I missed - Sadly we are still at the point where we can’t detect if Caps lock is on & the shift key is pressed on a Mac. On the bright side the updated plugin looks pretty solid.