views:

296

answers:

4

I was wondering if it was possible to know if the caps lock button is active while filling a web form ?

Sometimes, when you are asked to enter your password, softwares notice you that's active, and you be careful.

I would have liked to do the same in web forms.

Any ideas ?

+2  A: 

Take a look at this link: http://www.csua.berkeley.edu/~jgwang/capslock.htm

Praveen Angyan
This did not work in Chrome. jaS triggered popup.
jms
This only works completely in Internet Explorer. In Firefox/Chrome, typing a key while pressing the 'Shift' key when caps lock is on causes the detection to fail. This should work for most situations though.
Dan Herbert
Doesn't work like i want, if i press Shift + B i'm noticed.User should be able to use uppercase.
Boris Guéry
A: 

http://jdstiles.com/java/checkforcaps.html

joshcomley
Did not work in Firefox
Ascalonian
@Ascalonian - which version? It works in mine (3.5.3)
joshcomley
A: 

Accessing user setting like that would be against any decent security model, however you could check for whether the user has entered ALL_CAPS or aLL_CAPS and warn appropriately.

An elegant work-around can be found here: http://24ways.org/2007/capturing-caps-lock

Sadly, there’s no way of actually detecting whether Caps Lock is on directly. However, there’s a simple work-around; if the user presses a key, and it’s a capital letter, and they don’t have the Shift key depressed, why then they must have Caps Lock on! Simple.

Pool
I definitly think parsing user input like that would be a bad idea !my password could be FOOBAR and i don't want to be noticed !It should not disable the input to the user, but just notice him, that's caps lock is active.
Boris Guéry
You edit introduces a nice idea to check it
Boris Guéry
Yes, detect the shift key not the caps lock - simple and clever!
Pool
+6  A: 

Well i finally found exactly what i was looking for.

Here is a demo.

Here is the snippet.

Tested with IE7, Mozilla Firefox, Opera, Safari.

Boris Guéry
doesnt work with numbers
Chris