Java Robot keyPress(final int i, final Robot robot, final boolean press, final int keyCode, final int msDelay)

Here you can find the source of keyPress(final int i, final Robot robot, final boolean press, final int keyCode, final int msDelay)

Description

No validation is performed ..

License

Open Source License

Declaration

public static int keyPress(final int i, final Robot robot,
        final boolean press, final int keyCode, final int msDelay) 

Method Source Code

//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);
    }
}

Related

  1. awtRobotKeyPress(final Robot robot, final int keyCode, final int msDelay)
  2. awtRobotKeyRelease(final Robot robot, final int keyCode, final int msDelay)
  3. keyPressWithCtrl(Robot r, int key)
  4. pressKeyCombo(Robot robot, int... codes)