... or replace:
while(1)
with
while(key_pressed (key)) // key is 59 in the function, Scancode 59 = F1

The while breaks if you release the F1