my current and semi-working sketch:
const byte ROWS = 8; // rows
const byte COLS = 10; // columns
char keys[ROWS][COLS] = {
{ KEY_ESC, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9} ,
{ 0, 0, 0, 0, 0, KEY_BACKSLASH, 0, KEY_EQUAL, KEY_0, KEY_MINUS} ,
{ KEY_TAB, KEY_Q, KEY_W, KEY_E, KEY_R, KEY_T, KEY_Y, KEY_U, KEY_I, KEY_O},
{ 0, 0, 0, 0, 0, KEY_TILDE, 0, KEY_P, KEY_LEFT_BRACE, KEY_RIGHT_BRACE},
{ KEY_A, KEY_D, KEY_S, KEY_H, KEY_F, KEY_J, KEY_G, KEY_K, KEY_SEMICOLON, KEY_L},
{ KEY_Z ,KEY_X, KEY_C, KEY_V ,KEY_B, KEY_M, KEY_N, KEY_COMMA, KEY_PERIOD, KEY_SLASH},
{ 0 , 0 ,0 ,0, 0, KEY_BACKSPACE, 0 ,KEY_DOWN, KEY_LEFT, KEY_RIGHT},
{ 0, 0, 0, 0, 0 ,KEY_ENTER, 0 ,KEY_UP, KEY_SPACE ,KEY_QUOTE}
};
byte rowPins[ROWS] = {
0 ,1,2,3,4,5,8,9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
10,11,12,13,14,15,16,17,18,19}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
const byte ROWS2 = 1; // rows
const byte COLS2 = 4; // columns
char keys2[ROWS2][COLS2] = {
{MODIFIERKEY_SHIFT, MODIFIERKEY_SHIFT, 0 ,0 }
//{ 0 , 0 ,MODIFIERKEY_SHIFT, MODIFIERKEY_SHIFT }
};
byte rowPins2[ROWS2] = {
6}; //connect to the row pinouts of the keypad
byte colPins2[COLS2] = {
20,21,22,23}; //connect to the column pinouts of the keypad
Keypad keypad2 = Keypad( makeKeymap(keys2), rowPins2, colPins2, ROWS2, COLS2 );
void setup(){
}
void loop(){
char key = keypad.getKey();
char key2 = keypad2.getKey();
KeyState modifier = keypad2.getState();
if (key2){
Keyboard.set_modifier(key2);
}
KeyState alpha = keypad.getState();
if (key){
Keyboard.set_key1(key);
}
Keyboard.send_now();
if(modifier == RELEASED) {
Keyboard.set_modifier(0);
}
if(alpha == RELEASED) {
Keyboard.set_key1(0);
}
}
notice two getKey() lines. the first "alpha" keypad is responsive, and the second "modifier" works only occasionally. if i swap those lines, the opposite is true, which leads me to think that i'm asking too much of the teensy in each pass of the matrix scan.
would it be more likely to work if i used waitForKey() instead, and only read the modifier keypad if there's an alpha key pressed to modify?