[Request/Help] Holding the keyboard arrow for 0.5 mili second etc ...
Hello! Thanks for helping me if you decide to :)
But yeah, i am trying to do the following:
press Left Arrow Key for 1 second, then press up arrow key for 1 second then continue rest of the code!
I have looked all over the internet and i cannot find anything... when i try to use
robot.keyPress(KeyEvent.VK_LEFT);
robot.keyPress(KeyEvent.VK_UP);
// --> Continue rest of the application
it holds on left arrow key and stays looping forever... i even tried using timers but im i guess im not good enough to do that :(
Please help me, my kind friends!
/edit 2/
never mind.. i did it using a differe
Quote:
long t= System.currentTimeMillis();
long end = t+5000;
while(System.currentTimeMillis() < end) {
robot.keyPress(KeyEvent.VK_LEFT);
}
but now im wondering, how do i stop it from holding that key after the event is done?
Re: [Request/Help] Holding the keyboard arrow for 0.5 mili second etc ...
Well if you looked at the Robot's class API, you would see this nice method:
Code Java:
public void keyRelease(int key)
Which
Quote:
Originally Posted by Java SE 6 Robot API
Releases one or more mouse buttons.
Re: [Request/Help] Holding the keyboard arrow for 0.5 mili second etc ...
could you please explain a little more?
how do i use this in my little code to stop the left arrow key?