tags:

views:

376

answers:

3

I'm trying to build a better username/password field for my workplace and would like to be able to complain when they have their caps lock on.

Is this possible? And if so I'd like to have it detected before the client types their first letter.

+5  A: 

Try this, from java.awt.Toolkit, returns a boolean:

Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK)
Nick Craver
Good answer, sir!
Jarrod Dixon
+1  A: 

here is some info on the class http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Toolkit.html#getLockingKeyState(int)

Arthur Thomas
A: 

There's the Toolkit.getLockingKeyState() method, but it does (or did last time I looked) have some issues

A link can be found here

tim_yates