Due not working as a keeyboard

hello,

i have this code:

#include "Keyboard.h"
int i;

void setup() {
for (i=22; i<=53; i++){
  pinMode(i, INPUT);
  digitalWrite(i, HIGH);
  }
  pinMode(12, INPUT);
  digitalWrite(12, HIGH);
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  delay(10000);
  Keyboard.begin();
}

void loop() {
    

    if (digitalRead(22) == LOW){
      Keyboard.press('KEY_UP_ARROW');
      digitalWrite(13, HIGH);
    }
    if (digitalRead(22) == HIGH){
      Keyboard.release('KEY_UP_ARROW');
      digitalWrite(13, LOW);
    }
    if (digitalRead(23) == LOW)
      Keyboard.press('KEY_RIGHT_ARROW');
    if (digitalRead(23) == HIGH)
      Keyboard.release('KEY_RIGHT_ARROW');
    if (digitalRead(24) == LOW)
      Keyboard.press('KEY_DOWN_ARROW');
    if (digitalRead(24) == HIGH)
      Keyboard.release('KEY_DOWN_ARROW');
    if (digitalRead(25) == LOW)
      Keyboard.press('KEY_LEFT_ARROW');
    if (digitalRead(25) == HIGH)
      Keyboard.release('KEY_LEFT_ARROW');
    if (digitalRead(26) == LOW)
      Keyboard.press('1');
    if (digitalRead(26) == HIGH)
      Keyboard.release('1');
    if (digitalRead(27) == LOW)
      Keyboard.press(2);
    if (digitalRead(27) == HIGH)
      Keyboard.release(2);
    if (digitalRead(28) == LOW)
      Keyboard.press('KEY_LEFT_CTRL');
    if (digitalRead(28) == HIGH)
      Keyboard.release('KEY_LEFT_CTRL');
    if (digitalRead(29) == LOW)
      Keyboard.press('KEY_LEFT_ALT');
    if (digitalRead(29) == HIGH)
      Keyboard.release('KEY_LEFT_ALT');
    if (digitalRead(53) == LOW)
      Keyboard.press('5');
    if (digitalRead(29) == HIGH)
      Keyboard.release('5');
}

it does not work on both USB Ports, the4 LED connected on Pin 13 switches on if i put the output 22 to low.

so, where is my error?

even this doesnt work:

#include "Keyboard.h"

void setup() {
pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  delay(10000);
  Keyboard.begin();
  Keyboard.press('n');
  delay(500);
  Keyboard.release('n');
  delay(1000);
  Keyboard.write('a');
  delay (500);
  Keyboard.print('v');
  delay (500);
  Keyboard.end();
}

void loop() {
    delay (500);
    digitalWrite(13, HIGH);
}

the same code works fine with the leonardo

EDIT:

Hello McKaiver,

Your keyboard code only works with the Native USB.

To verify that your Due communicates ok with your computer, try the following example.

void setup() {
  Keyboard.begin();
}

void loop() {
    Keyboard.println("Hello World");
    delay(5000);
  }

Open any text edit to read the "Hello World" text.

Due and Leonardo MCUs are completely different. Due has SAM and Leo has AVR.

-p