Is it possible to allow an Arduino Leonardo to simulate pressing the Windows key using the keyboard.press(......); command?

If so, what is the required value?

  • 1
    Add a delay(20) after the keyoress
    – Darwyn
    Commented Jun 30, 2018 at 5:05
  • if i want to press numbers key which value I need to enter in program?? Like I want to press Control Key + number Key 1... Keyboard.press(KEY_LEFT_GUI); Keyboard.press('which value I need to enter for key 1?'); Keyboard.releaseAll(); Commented Nov 27, 2018 at 7:09

2 Answers 2


They Keyboard.press() command accept modifiers per the documentation. You may need to do multiple press() commands before releasing.

For example, if you want to launch File Explorer you could use:


This is equivalent to shortcut keys Win + E.

The modifier GUI is what stands in for the "command key" which is the Windows Logo on a PC or clover (⌘) on a Mac.

I don't have any restriction on the higher value on my board (Pro Micro), as indicated by @frarugi87.


Looking at the list of the HID keyboard codes (page 53), the keys you are looking for have a code of E3 (Keyboard Left GUI) or E7 (Keyboard Right GUI).

Unluckily the Keyboard::press function (you can see it here) does not accept a so high value, since you can only input numbers between 0 and 255 and, in order to send a raw value, you have to send its value plus 136 (which leads to values 363 and 367).

However, looking at the header file, there are two predefined keys called KEY_LEFT_GUI and KEY_RIGHT_GUI. Maybe these modifier keys behave in exactly the same way.

So my suggestion is to

  1. try using one of those values (i.e. keyboard.press(KEY_LEFT_GUI); or keyboard.press(KEY_RIGHT_GUI);, or use the keyboard.write(KEY_LEFT_GUI); to simulate a press on the key instead of you keeping it pressed).
  2. If this does not work, create your own library copying the keyboard.cpp and keyboard.h files, calling the class differently and adding the possibility to send the E3 and/or the E7 keys. In this case, you will just need to modify the press function.

Good luck

Not the answer you're looking for? Browse other questions tagged or ask your own question.