Robot press Enter Key - Java java.awt

Java examples for java.awt:Robot

Description

Robot press Enter Key

Demo Code


//package com.java2s;
import java.awt.AWTException;
import java.awt.Robot;

import java.awt.event.KeyEvent;

public class Main {

    public static void pressEnterKey() {
        Robot robot = null;//  w  ww  . j a  v  a2s .co  m
        try {
            robot = new Robot();
        } catch (AWTException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);
    }
}

Related Tutorials