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?

  • Add a delay(20) after the keyoress – Darwyn Jun 30 '18 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(); – chauhan anand Nov 27 '18 at 7:09

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 Explorer you could use:


This is equivalent to shortcut keys windows + e

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

I am not having 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

protected by Community Nov 27 '18 at 11:42

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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