As a quick test, I tried running this on a Teensy 3.2 with a couple pushbuttons connected.
Code:
#include <Bounce.h>
Bounce button1 = Bounce(1, 5); // 5 = 5 ms debounce time
Bounce button2 = Bounce(2, 5);
void setup() {
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
}
void loop() {
button1.update();
button2.update();
if (button1.fallingEdge()) {
Keyboard.press(KEY_LEFT);
}
if (button2.fallingEdge()) {
Keyboard.press(KEY_RIGHT);
}
if (button1.risingEdge()) {
Keyboard.release(KEY_LEFT);
}
if (button2.risingEdge()) {
Keyboard.release(KEY_RIGHT);
}
}
It seems to work fine. If fact it's still running while I type this message, and if I reach over and tap the 2 buttons, my cursor moves back and forth.
Tested with Teensy 3.2, all settings at defaults, except of course Tools > USB Type set to Keyboard. Here's the hardware on my workbench used for this quick test.