How can I get this code to wait for a key up event before firing again?

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);
}

You need to look at the state change detection example. You should be acting only when the state changes from not-pressed to pressed. Of course, that requires that you keep track of the previous state of the switch, so that you can detect the state change.

There's a really quick fix if your program doesn't need to do anything else:

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);
    while(digitalRead(10) == LOW)    // Add these two lines
      ;                              // Do nothing while the button is down.
    delay(1000); 
    }
  delay(10);
}

Thanks TanHadron! That's exactly what I need. Awesome!