I know that there is a lot of forum discussion regarding using a Photon as a Human Interface Device. I have read all of the previous threads regarding HID. We have a simple script which I will include below. The Keyboard.print() function works well, however, Keyboard.press() and Keyboard.write() do nothing at all. I have tried key codes i found on these forums, as well as the codes on https://www.arduino.cc/en/Reference/KeyboardModifiers . Even Keyboard.press(‘n’) does not work. Thanks for the help, here is the code:
void setup() {
Keyboard.begin();
}
void loop() {
delay(1000);
Keyboard.write(131); //Should press the left windows key, but does nothing
delay(1000);
Keyboard.print("www.deagware.xyz"); //print works
delay(100000);
}
It should be noted I am using the 0.6.0-rc.2 firmware on a Photon
That might explain why your code doesn't work, which doesn't mean the function doesn't do what it's supposed to do.
And for press() you might want to try a release() too - or just the click() which bundles both.
And as for your Keyboard.press('n') what did you expect to happen, and what do the docs say should happen?
'n' equals 0x6E which in turn maps toKEY_F19 = 0x6E, // Keyboard F19
Did you check if KEY_F19 was pressed or did you expect to get a load of letters n typed?
Did you make any progress on this? It looks like @ScruffR explained why write didn’t work.
It looks like click() should work however the Windows key isn’t called out in the keycode enum map. From this SO post it looks like it could be 5B or 5C which map to KEY_KP_3 and KEY_KP_4 respectively in the keycode enum map.
EDIT: Looks like it’s actually KEY_LEFTGUI and KEY_RIGHTGUI as @avtolstoy mentions below