Wednesday 26 June 2013

How to check Caps Lock on

I've been using this method to confirm if caps lock key on the keyboard is on or not. Here it is, Just thought of sharing it might ne useful to you
I've been using this method to confirm if caps lock key on the keyboard is on or not. Here it is, Just thought of sharing it might ne useful to you

import java.awt.Toolkit //for the Toolkit class

public static boolean checkCapsLock(){
     boolean pressed = false
     if(Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK) == true){
          pressed = true;
     }
     return pressed;
}

No comments:

Post a Comment

Your suggestion counts...