Simulate a key press : Robot « Development Class « Java






Simulate a key press

   
 
import java.awt.Robot;
import java.awt.event.KeyEvent;

public class Main {
  public static void main(String[] argv) throws Exception {

    Robot robot = new Robot();

    robot.keyPress(KeyEvent.VK_A);
    robot.keyRelease(KeyEvent.VK_A);

  }
} 

   
    
    
  








Related examples in the same category

1.Moving the Cursor on the Screen
2.Simulate a mouse click
3.Create mouse event using Robot class
4.Capture a screenshot
5.Get the colour of a screen pixel
6.Capturing a Screen Shot
7.Capturing Screen in an image using Robot class
8.Create key press event using Robot class?
9.Use Robot to do mouse press
10.Using Robot to capture a screen shapshot
11.Use Robot to send combo key event