Click to See Complete Forum and Search --> : Form KeyPress event


gibea00
April 30th, 2003, 08:52 AM
Hi

i would like to let the user close the form by pressing the escape button.

I tried to edit the keyPress event of the form, but that doesn't work...nothing append.

To do that ... do i have to edit the keypress event for each of the controls that are in my form ?

Thanks for your help

wolfofthenorth
April 30th, 2003, 09:13 PM
If you have an exit button, you could set the form's CancelButton property to it. The CancelButton is called automatically when the user presses the Escape Key.

Or you can trap for the Escape Key in the KeyUp or KeyDown events. I can't rember for sure, but I think these events will fire for the Escape key while the KeyPress event won't??

Hope this helps.