>How do I make the ESCape key close a form? I suppose I could put an invisible button on the form with escape as the default. Is that the best way. I tried to use ON ESCAPE but couldn't get it to work.
Create a CommandButton and set it's Cancel property to .T. - the Click() event will fire for the Control. Note that the Valid and LostFocus events of whatever control is currently in Focus will fire; you may want to alter you Valid() code to check to see if the Cancel action was triggered. Also realize that the Escape may not fire immediately; VFP doesn't process the pending keyboard event until it looks at the Windows message queue - in long, compute-intensive operations, or in a single routine that makes no UI references and never makes a call to another method, function or procedure, VFP generally won't look - making calls to DOEVENTS() will force VFP to process pending events. DOEVENTS() has a noticable impact on performance; call it at intermittent intervals inside a tight loop rather than on each pass should be adequate, and prevents the user from thinking that the app has 'locked up'. VFP can only check for events between lines of code, so single statements that need a long time to complete will have the same behavior; adding a reference to a UDF() that updates a progress bar or calls DOEVENTS() give the event handler a chance to fire, with the obvious cost of overhead.