If you want to use the same keys throughout your application, you need to use the AutoKeys-Macro (with the AutoExec-Macro all you need to know about Macros).
The technique is as follows:
Write {F2} for the F2-key, {ESC} for escape-key
EXECUTECODE
SubAutokeys("F2")
SubAutokeys("ESC")
Then...