I don't know about QBASIC having ON KEY, I haven't used that in a VERY long time- QuickBasic 4.5 likely has it, however.
Generally, you have ON KEY (keycode) GOTO (label)
and then you have the code for that keycode- I believe the exact syntax is presented in the online help.
On the other hand, Now that I think about it- there is no way to perform the flag testing I mentioned beforehand, so I'm not sure how that would work...
I just did, however, recently recall what a "null string" means in QB- Instead of comparing to an empty string "" as I did, I believe one would have to use VarPtr or StrPtr or a similiar function, to determine that it's pointer isn't 0.
I apologize for my vagueness, I haven't done QB very much in over 3 or 4 years. If I get time I might check this out myself, but I'm almost positive there will be some use of a Pointer-type function.