Java Swing Key Event press(int key)

Here you can find the source of press(int key)

Description

press

License

Apache License

Declaration

public static void press(int key) 

Method Source Code


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

Related

  1. esFecha(KeyEvent e)
  2. insertKeyListener(Component component, KeyListener l, int index)
  3. keyEventGetKeyText(int keycode)
  4. keyEventModifiersToKeyStrokeModifiers(int modifiers)
  5. keyStrokeModMac(String keyStrokeStr)
  6. pressKey(final int key)
  7. recipientHintSelected(String hintString, TextField toList, boolean shiftKeyPressed)
  8. rejectNonNumericKeys(KeyEvent evt)
  9. retargetKeyEvent(KeyEvent e, Component target)