Keyboard.h commands not executing on Leonardo

I have attempted to setup my Arduino Leonardo to input three keystrokes as soon as my pc boots so that it will boot to my Windows OS. The delay before the commands are executed is not an issue and the compiler doesn't find any errors in my code, but the commands still won't execute. If someone could please take a look at my code and give me some advice, it would be greatly appreciated. I'm really new at C++ and this is my first Arduino Project.

#include "Keyboard.h"

int var = 0;

void setup() {
  pinMode(13, OUTPUT);
  Keyboard.begin();
}
void loop() {
  while (var == 0){
    Keyboard.press(KEY_DOWN_ARROW);
    digitalWrite(13, HIGH);
    delay(100);
    Keyboard.release(KEY_DOWN_ARROW);
    digitalWrite(13, LOW);
    delay(100);
    Keyboard.press(KEY_DOWN_ARROW);
    digitalWrite(13, HIGH);
    delay(100);
    Keyboard.release(KEY_DOWN_ARROW);
    digitalWrite(13, LOW);
    delay(100);
    Keyboard.press(KEY_RETURN);
    digitalWrite(13, HIGH);
    delay(100);
    Keyboard.release(KEY_RETURN);
    digitalWrite(13, LOW);
    var++;
   }
}
 Keyboard.begin();
  /
}

I’m surprised the compiler doesn’t complain about the lone slash there.

If you only want something to run once, don’t mess about with flags, just put the code in setup.

Why on earth would you use a while loop, knowing full well that it will iterate exactly once?

the slash must have remained from the commented parts i had removed.

I have tried it both ways- with the loop that runs only once and with the executing code in the setup() class.

#include "Keyboard.h"

int var = 0;

void setup() {
  pinMode(13, OUTPUT);
  Keyboard.begin();
  Keyboard.press(KEY_DOWN_ARROW);
    digitalWrite(13, HIGH);
    delay(100);
    Keyboard.release(KEY_DOWN_ARROW);
    digitalWrite(13, LOW);
    delay(100);
    Keyboard.press(KEY_DOWN_ARROW);
    digitalWrite(13, HIGH);
    delay(100);
    Keyboard.release(KEY_DOWN_ARROW);
    digitalWrite(13, LOW);
    delay(100);
    Keyboard.press(KEY_RETURN);
    digitalWrite(13, HIGH);
    delay(100);
    Keyboard.release(KEY_RETURN);
    digitalWrite(13, LOW);
}
void loop() {
  
}

What application on the PC is active when you run that code? What evidence do you have to back up your claim that "the Arduino is not working"?

I had a previous error that I had sorted out that had repetitively input the letters "N" and "W". It had input it in the Arduino Coding console. I have reset the Arduino while on multiple different screens such as Explorer.exe and the Arduino Coding console where they should have a visible effect, ie. moving highlighted objects and opening a folder, as would happen if one were to press "Down" and "Enter/Return" on a standard keyboard while running the applications.