Java Robot awtRobotKeyPress(final Robot robot, final int keyCode, final int msDelay)

Here you can find the source of awtRobotKeyPress(final Robot robot, final int keyCode, final int msDelay)

Description

awt Robot Key Press

License

Open Source License

Declaration

private static void awtRobotKeyPress(final Robot robot,
            final int keyCode, final int msDelay) 

Method Source Code

//package com.java2s;

import java.awt.Robot;

public class Main {
    private static void awtRobotKeyPress(final Robot robot,
            final int keyCode, final int msDelay) {
        robot.keyPress(keyCode);/*from  ww w .  ja v  a  2s  .  c  om*/
        robot.delay(msDelay);
    }

    /** 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 {
            awtRobotKeyRelease(robot, keyCode, msDelay);
        }

        return (int) (System.currentTimeMillis() - t0);
    }

    private static void awtRobotKeyRelease(final Robot robot,
            final int keyCode, final int msDelay) {
        robot.keyRelease(keyCode);
        robot.delay(msDelay);
    }
}

Related

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