Hello, I'm new to this forum and to arduino. I'm trying to setup a keyboard emulator with a 32u4 chip arduino.
I can get it to give me a character by pressing a button but I can't seem to get it to give me more when I hold the button down. I've tried a few different things but with no luck..
I would love some help,
Here's the code that's so far working for me
#include <Keypad.h>
#include <Keyboard.h>
const byte ROWS = 7; //four rows
const byte COLS = 6; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'w','i','1','7','c','v'},
{'a','j','2','8','m','u'},
{'s','k','3','9',',','.'},
{'d','l','4','0','z','x'},
{'e','h','5','t','b','g'},
{'q','n','6','r','y','o'},
{' ',' ','[',']'}
};
byte rowPins[ROWS] = {6, 5, 4, 3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {16, 15, 14, 9, 8, 7}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
}
void loop(){
char customKey = customKeypad.getKey(); //figure out which key
if(customKey == 'y') {
Keyboard.press(8); //8 is ASCII code for backspace
delay(100);
Keyboard.releaseAll();
} else if(customKey == 'o'){
Keyboard.press(' ');
delay(100);
Keyboard.releaseAll();
}else if(customKey) {
Keyboard.press(customKey);
delay(100);
Keyboard.releaseAll();
delay(10);
}
}
keyboard.txt (1.38 KB)