0

I'd like to simulate the "0" number input in Java, i've heard about Robot but can they also simulate int input? Actually i know only this shortcode:

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);    // confirm by pressing Enter in the end, but i want to enter "0"  before and after press enter...
robot.keyRelease(KeyEvent.VK_ENTER);

1 Answer 1

1

Simply use

    robot.keyPress(KeyEvent.VK_0);
    robot.keyRelease(KeyEvent.VK_0);

There is no way to "truly" simulate that an integer comes from the keyboard. The keyboard delivers ascii characters, and it doesn't know which once that qualify as integers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.