Here you can find the source of keyPress(final int i, final Robot robot, final boolean press, final int keyCode, final int msDelay)
public static int keyPress(final int i, final Robot robot, final boolean press, final int keyCode, final int msDelay)
//package com.java2s; import java.awt.Robot; public class Main { /** No validation is performed .. */ public static int keyPress(final int i, final Robot robot, final boolean press, final int keyCode, final int msDelay) { final long t0 = System.currentTimeMillis(); if (press) { awtRobotKeyPress(robot, keyCode, msDelay); } else {/*from www . ja v a 2 s . co m*/ awtRobotKeyRelease(robot, keyCode, msDelay); } return (int) (System.currentTimeMillis() - t0); } private static void awtRobotKeyPress(final Robot robot, final int keyCode, final int msDelay) { robot.keyPress(keyCode); robot.delay(msDelay); } private static void awtRobotKeyRelease(final Robot robot, final int keyCode, final int msDelay) { robot.keyRelease(keyCode); robot.delay(msDelay); } }