Here you can find the source of press(int key)
public static void press(int key)
//package com.java2s; //License from project: Apache License import java.awt.*; public class Main { public static void press(int key) { Robot robot = null;// www. ja v a 2 s .c o m try { robot = new Robot(); } catch (AWTException e) { e.printStackTrace(); } robot.setAutoDelay(80); robot.keyPress(key); robot.keyRelease(key); try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } } }