Arduino Due Keyboard Output does not work (shows up in serial monitor)


I have programmed my SainSmart Due to read input from two keypads and would now like to send keyboard signals to my attached computer (e.g. when pressing “1” on the keypad the Arduino should send “1” as a keyboard stroke / signal to my computer so I see “1” in notepad. The keys show up in the serial monitor just fine but I can’t get the thing to send keystrokes to my computer :frowning:

    if(key2)  // Check for a valid key.
    switch (key2)
      case '*':
          digitalWrite(ledpin, HIGH);
      case '#':

        digitalWrite(ledpin, LOW);


“key2” can be numbers from 0 to 9 and letters from A to D. They show up just fine in the serial monitor.

Any help would be greatly appreciated!

Thanks a lot in advance and best wishes,

Without seeing any of the rest of your sketch you could try replacing Keyboard.print with Keyboard.write i.e.

Keyboard.write(byte key2);

It's working for me like that.

This may not be relevant to your situation but I found out, at least in my case (Mac OS X), that the DUE would only transmit keyboard input from the Native USB port. A sketch I wrote that transmitted keyboard input to my Mac worked with a Leonardo but wouldn't with a DUE until I switched connected to the Native USB port.


Thanks to you both for considering my question. Actually just plugging in the board to the native port was what fixed the issue!

(I received a debug error for "Keyboard.write(byte key2);" which I tried first.)

Thanks a lot and best wishes,

Maybe you're using the programming port, without realizing the USB Keyboard stuff works only on the native port?