Page 1 of 1

[Solved] Macro: What key is pressed in key down event

Posted: Thu Jun 25, 2009 10:20 am
by mark_orion
I want to write a macro that gets triggered by a "key down" event and reacts depending on what key has been pressed. The "key down" part is easy as the events property of the form control has it, but how do I get the information about WHAT key is down ?

Re: Macro needs to know what key is pressed in key down event

Posted: Thu Jun 25, 2009 5:40 pm
by FJCC
I made a text box and set it to trigger a macro on "key down". The macro expected to be passed a parameter oEv. Here is the Macro

Code: Select all

Sub Main(oEv)
xray oEv

End Sub
When I pressed Shift- A I got this from xray

Code: Select all

KeyChar                   char                        "A"   
KeyCode                   integer                     512   
KeyFunc                   integer                       0   
Modifiers                 integer                       1   
Source                    object                            
So oEv.KeyChar is one way to find out what key was pressed.

Re: Macro needs to know what key is pressed in key down event

Posted: Fri Jun 26, 2009 4:35 pm
by mark_orion
FJCC wrote:I made a text box and set it to trigger a macro on "key down". The macro expected to be passed a parameter oEv. Here is the Macro
So oEv.KeyChar is one way to find out what key was pressed.
Works excellent - thank you!