It must be some bug. I swapped the ON/OFF switch for an ON/ON and solved with
int togglePin1 = 9;
int togglePin2 = 10;
if (digitalRead(togglePin1) == HIGH) {
char key = keyp1.getKey();
if (key != NO_KEY) {
Serial.println(key);
Keyboard.press(key);
delay(150);
Keyboard.release(key);
}
}
if (digitalRead(togglePin2) == HIGH) {
char key = keyp2.getKey();
if (key != NO_KEY) {
Serial.println(key);
Keyboard.press(key);
delay(150);
Keyboard.release(key);
}
}
Any of the other solutions would result in the same issue.