Here is what I’ve got so far.. I’m using this as a keybind. I want to press the “Down” arrow key anytime the app is running, and then make it auto press the “Down” arrow key 3 extra times then finish by pressing “Enter” in the code. I know this isn’t the best explanation but sorry and I will try to explain it any better if you still didnt understand.
Here is the code:
public class MyKeyListener extends KeyAdapter{
@Override
public void keyPressed(KeyEvent evt){
}
KeyListener keyListener = new KeyListener() {
@Override
public void keyPressed(KeyEvent keyEvent) {
int keyCode = keyEvent.getKeyCode();
if(keyCode == 1005){
System.out.println("So far, so good..");
}
}
@Override
public void keyTyped(KeyEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void keyReleased(KeyEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
};
I think the Key arrow down is 1005.
I’ve so far wrote System.out.println(“So far, so good..”); to see if the app even detects it when I press the down arrow key, but it doesn’t…
Any ideas please?
I’m just throwing this out there because I think it MAY be useful to you, this is a virtual Java keyboard, modified from some resource I found on the web years ago and which I no longer remember the link to:
To modify this to your needs, you would do:
The doType(KeyEvent.VK_DOWN); would press down one time, and then also release it.
You would probably insert that after the “So far, so good…” part in your code.
Hope I helped!