Monday, February 3, 2014

Caps Lock Status Displaying

import java.awt.*;
import java.awt.event.*;
class statuscaps
{
   public static void main(String args[])
   {
      boolean status = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
      if(status)
         System.out.println("You Caps Lock is on");
      else
         System.out.println("You Caps Lock is off");
   }
}

Set Caps Lock on Program

class capslockon
{
   public static void main(String args[])
   {
      java.awt.Toolkit.getDefaultToolkit().setLockingKeyState(java.awt.event.KeyEvent.VK_CAPS_LOCK, Boolean.TRUE);
   }
}