onChar
Event fired when a "printable" key or key combination is pressed while the control has focus.
Parameters
<char expN>
The ASCII code of the key or key combination
<repeat count expN>
The number of times the keystroke is repeated based on how long the key is held down.
<key data expN>
A double-byte value that contains information about the key released, stored in separate bit fields. The bits of this parameter contain the following information:
Bit numbers |
Description |
0–7 |
Keyboard scan code (OEM dependent) |
8 |
Extended key (1 if true) such as right Alt and Ctrl, and numbers on numeric keypad |
9–12 |
Reserved |
13 |
Context code: 1 if Alt was pressed during keystroke |
14 |
Previous key state: 1 if key was held down |
15 |
Transition state: 1 if key is being released, 0 if key is pressed (usually 0) |
Property of
PaintBox
Description
If you have created a PaintBox object to develop a custom edit control, use onChar to do something when the object has focus and the user presses a key; that is, when they type a normal character.
onChar is similar to onKeyDown. However, onChar doesn’t fire for non-printable keys, such Caps Lock, while onKeyDown fires for any key pressed.