I\'m looking to simulate the action of holding a keyboard key down for a short period of time in Java. I would expect the following code to hold down the A key for 5 seconds
Just keep pressing?
import java.awt.Robot;
import java.awt.event.KeyEvent;
public class PressAndHold {
public static void main( String [] args ) throws Exception {
Robot robot = new Robot();
for( int i = 0 ; i < 10; i++ ) {
robot.keyPress( KeyEvent.VK_A );
}
}
}
I think the answer provided by edward will do!!