Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Passing keyboard event programmatically

Vivek Gade
5 years ago May 04, 2016 8:36am
Nick Rapellas
5 years ago May 17, 2016 2:35pm

Hi,
I suppose you mean "press a specific button at the keyboard??"
I'm using the following code with success...

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent
obot robot;
            try {
                robot = new Robot();
                robot.keyPress(KeyEvent.VK_F11);
                robot.keyRelease(KeyEvent.VK_F11);
            } catch (AWTException e) {
                LogManager.error(logger, "F11 key could not be pressed",e);
            }