Currently I am using java.awt.Robot to perform key presses. The application I am developing requires long presses. I can't just use a loop and perform repeated presses. Every question posted on this website provides one of the three solutions -

> 
> make the thread go to sleep -
> 
> 
> 

```
public static void main(String[] args) {
    try {
        Robot robot = new Robot();
        Thread.sleep(5000);
        int key = KeyEvent.VK_W;
        robot.keyPress(key);
        Thread.sleep(5000);
        robot.keyRelease(key);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

```

> 
> try using the robot's delay function -
> 
> 
> 

```
public static void main(String[] args) {
    try {
        Robot robot = new Robot();
        Thread.sleep(5000);
        int key = KeyEvent.VK_W;
        robot.keyPress(key);
        robot.delay(5000);
        robot.keyRelease(key);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

```

> 
> the third one is the repeated pressing which isn't something I can implement into my project.
> 
> 
> 

1st and 2nd don't work and third is unusable for my project.

I am using a windows 11 machine with 22H2 update (i.e. latest version)