Key Events Overview

Key events

Guidelines for assigning Key UP or Key Down keys

Details for the Key parameter

Key events

Key Down

Key Up

While Key Down

Guidelines for Assigning Key Up or Key Down Keys

You may assign most keys as a Key Down or Key Up event. However, when you do, the triggered procedure overrides any other function the key may have performed.

Do not use:

Ctrl, Shift, or Alt alone

Esc, Tab, Enter, or Print Screen either alone or in combination with other keys.



Ctrl+Scroll Lock

Ctrl+Shift+Scroll Lock

Ctrl+Alt+Scroll Lock


Ctrl+Pause (regardless of other modifiers like Shift and Alt)

You may assign a key that would normally invoke a menu or Help. If no procedure is assigned, the normal action is invoked. Keys that are affected are:


Accelerator Action


File Open


File Print


Help Contents


Context Help


Select Frame Menu


Close Window

(Note: The window will close after the procedure is done.)

Details for the Key parameter

The low-order byte represents the Windows virtual keycode of the key that was pressed. For ASCII letters and numbers, this corresponds to the ASCII code for that character.

The high order byte has information about the state of the Alt, Control, and Shift keys. The other bits are currently reserved and should not be used. The values are:







To extract just the high order byte containing the modifier states and the low order byte containing the key code, you can use the following sample code:

modifiers=key / 256

keycode=key mod 256

Since the modifiers are bit values, you must use the binary AND operator to test them.


If modifiers And gefModAlt Then

  ' do something

End If


More information

Available events.