PDA

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


Rick H
Jan 26th, 2000, 06:46 PM
I cant seem to get Keypress to work.

I have a form, when the user presses ESC I want an event to happen. I have tried

Private Sub Form_KeyPress(KeyAscii As Integer)

Keydown and Keyup, none of these seem to work. Is Form_.... the right place, or should it be somewhere else????

My form is a MDIChild.

michelle
Jan 26th, 2000, 07:06 PM
Hello Rick,

The keypress will only work for your form if it is an empty form.

If you have components on your form I do think all of them heve to configured for your ESC key.

Nice regards,

michelle.

Rick H
Jan 26th, 2000, 07:23 PM
I thought about that, but its a bit long winded.

I was wondering wether I could have an invisable button with an accelerator (short cut) key, but I`m not sure if its possible to implement shortcut keys with buttons. do you know if this is possible?

Crazy D
Jan 26th, 2000, 07:23 PM
Set the keypreview property of the form to True, then you can use the form_keydown event to catch the escape key (and if you need to know what control has the focus, you can use ActiveControl( .Name ) )

Hehe you replied while I replied... you can set the Cancel property of a commandbutton to true, but the button needs to be visible.

[This message has been edited by Crazy D (edited 01-27-2000).]

Rick H
Jan 26th, 2000, 07:26 PM
I know!, I got there first though. I have used the Keypreiew option, works a treat.
Cheers


[This message has been edited by Rick H (edited 01-27-2000).]