emulate computer keyboard

Hi everybody,

I am trying to emulate a computer keyboard with my teensy (Teensyduino)and the bounce library.When I push a button, the arduino prints a character, for example “A”.
My problem:

When I hold the pushbutton down it has to print the char in sequence like a computer keyboard, but I cant get it to work.

video of the problem:

my code:

// The inputs you're using for button presses
#include <Bounce.h>
const int button1 = 5;     
const int button2 = 8;    
const int button3 = 6;    


Bounce bounce1 = Bounce( button1,10 ); 
Bounce bounce2 = Bounce( button2,10 ); 
Bounce bounce3 = Bounce( button3,10 ); 
void setup() {
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);  
  pinMode(button3, INPUT);    
}
 
void loop(){
  bounce1.update ( );
  bounce2.update ( );
  bounce3.update ( );

// If button1 button is pressed
  if (bounce1.fallingEdge()) {   
    Keyboard.set_key1(KEY_A);
    Keyboard.send_now();
    Keyboard.set_key1(0);
    Keyboard.send_now();
      
  } 
 
// If button2 button is pressed
 if (bounce2.fallingEdge()){
     // Change the following two lines to change the keys sent    
    Keyboard.set_key1(KEY_B);
    Keyboard.send_now();
    Keyboard.set_key1(0);
    Keyboard.send_now();
 
  } 
  // If button  button is pressed
   if (bounce3.fallingEdge()) {
    Keyboard.set_key1(KEY_C);
    Keyboard.send_now();
    Keyboard.set_key1(0);
    Keyboard.send_now();
     
  } 
  
}

thank you in advance.

Engin

You code is currently looking for button transitions and only outputs the character when the button state changes.

To get behaviour corresponding to a conventional keyboard autorepeat, you also need to test whether the key remains held down and your autorepeat interval has passed since the last character was output.

There are lots of different ways to code this, but the simplest approach needs you to poll the key state (up/down) and output the character at timed intervals as long as the key remains down.