There could be a command to switch on/off/change the $key value (depending on what $key ultimately returns).

Code:
f1 {
  if ($key) {  ; [color:red]if ($key == F1) {[/color]
    ;do something here
    ;do something else
  }
}

f6 {
  key on    ;[color:red]key F1[/color]
  f1
}


Alternate format in red

-genius_at_work