Usb keybord+arduino due

Hello ,

i have successfully interfaced usb keyboard and printing value on serial monitor.
in my program" enter_name() " this function print value of pres key but when i same key two time it print only one time. what improvement should i done in this function to solve my problem.


#include <KeyboardController.h>

// Initialize USB Controller

USBHost usb;

// Attach keyboard controller to USB

KeyboardController keyboard(usb);



char key,key1;
 

void setup()
{i=0;


  Serial.begin(115200);

  Serial.println("Program started");

   delay(200);
}

void enter_name(){
  
 usb.Task();// Process USB tasks
    key=keyboard.getKey();
//////////////////// I lock it because keyboard.getKey(); give same value two time////////////   
if(key1!=key) 
 {Serial.println(key); key1=key;} 
 return;

  }
  
void loop()
{
 enter_name();


}

To get rid of your issue with keys showing up twice, you added code so you can never have the same key twice in a row.

To fix it, add a void keyPressed() function which will get called each time a key is pressed. In that function you call keyboard.getKey() to get the key value.