Robot press Esc Key - Java java.awt

Java examples for java.awt:Robot

Description

Robot press Esc 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 pressEscKey() {
        Robot robot = null;//from   ww  w.  j ava 2 s.com
        try {
            robot = new Robot();
        } catch (AWTException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        robot.keyPress(KeyEvent.VK_ESCAPE);
        robot.keyRelease(KeyEvent.VK_ESCAPE);
    }
}

Related Tutorials