So I have a code that sends an F4 key press when a button is pressed. It also waits 1 second before allowing another key press. This is good. But what I'd also like it to do is wait, in the event that the button is held down, until the button comes up again before allowing another key press. I have made this happen before with keyboard.print, but that doesn't send an F4.
Here's the code. Any info would be very helpful. As you can see, I'm still learning, so please try to explain things. Thanks so much!
void setup() {
Serial.begin(9600);
pinMode(10, INPUT);
digitalWrite(10, HIGH); // pullup
}
void loop() {
if (digitalRead(10) == HIGH) {
delay(10);
} else {
Keyboard.set_key1(KEY_F4);
Keyboard.send_now(); // press F4
delay(10);
Keyboard.set_key1(0);
delay(1000);
}
delay(10);
}