KeyUp Event
Object List Next Object
Defined By: Drawable
Description:
Occurs when the user releases a key while an object has the focus. It is
commonly used in combination with the KeyUp event to process the press and/or
release of any key (compare to the KeyPress event, which receives only ANSI
characters).
Usage:
Sub KeyUp (keyCode As Integer, ByVal shift As Integer)
Syntax Description
KeyCode Provides a unique number identifier, or key code, for the key pressed. The key
code is the virtual-key value as defined by the Win32 API. Constants are
provided with Phoenix to make key event handling code more readable, e.g. KEY_DELETE
(Del key) and KEY_F2 (F2 key). Key code constants are defined in the “KEYCODES” module.
Shift Indicates the status of the SHIFT, CTRL, and ALT keys at the time the event
was called. Each of these keys has a corresponding bit-flag value. SHIFT has a
value of 1, CTRL is 2, and ALT is 4. To indicate which key or keys were pressed,
the key values are summed in the Shift argument. For example, if both CTRL and ALT are pressed, the value of Shift is 6.
Details:
The object with the keyboard focus receives all keystrokes. Generally, this
object is a control. A form receives key events only if it has no active controls
or if the form's KeyPreview property is set to True. When a form's KeyPreview
property is set to True, the form receives key events before the controls on
the form, and can modify the key that will be seen by the control when it
receives the event. This is useful for creating form-specific keyboard-handling
routines, such as special shortcuts or accelerators.
A KeyDown event with the same KeyCode value is received at least once before a KeyUp event occurs. The KeyUp event
is only executed once per keystroke when the user releases the key. This allows
you to disable automatic repetition of keys on the keyboard.
The KeyUp event can process all keys, not just character keys. However, it is
most commonly used to distinguish between the numeric keypad and regular
numbers or to react to users pressing:
Extended character keys such as function keys.
Navigation keys such as arrow keys.
Key combinations such as CTRL-SHIFT-key.
To test for the Shift argument, you can declare constants that define the bits
within the argument. The Shift constants have the following values:
Constant Value Bit
SHIFT_MASK 1 0
CTRL_MASK 2 1
ALT_MASK 4 2
You can use these constants to test for any combination of buttons.
Note: To interpret ANSI characters, use the KeyPress event.
See Also:
KeyPreview property