When you press the W button with the Robot class, the character does not go forward : To get acquainted with the class robot decided to make a program that would control the character from the game Minecraft, but unfortunately this code does not work in the game. The letter is printed in a notebook, but can not get the character out of the game to walk(

    import java.awt.*;
    import java.awt.event.KeyEvent;
    
    public class Main {
        public static void main(String[] args) {
            try {
                Robot robot = new Robot();
                robot.keyPress(KeyEvent.VK_W);
                robot.delay(1000);
                robot.keyRelease(KeyEvent.VK_W);
            } catch (AWTException e) {
                e.printStackTrace();
            }
        }