key
Event fired when the user types a keystroke in a control; return value may alter or cancel the keystroke.
Parameters
<char expN>
The ASCII value of the character typed.
<position expN>
The position of the new character in the string.
<shift expL>
Whether the Shift key was down.
<ctrl expL>
Whether the Ctrl key was down.
Property of
ColumnEditor, ComboBox, Editor, Entryfield, ListBox, SpinBox
Description
Use key to evaluate and possibly modify each character that the user enters in a control, or to perform some action for each keystroke.
The key event handler must return a numeric or a logical value. A numeric value is interpreted as the ASCII code of a character, which automatically replaces the character input by the user. A logical value is interpreted as a decision to accept or reject the character input by the user.
Keystrokes simulated by a control’s keyboard( ) method will fire the key event, as will the KEYBOARD command when the control has focus.
Note
You cannot trap all keystroke combinations with key. Many Alt+ and Ctrl+ key combinations are reserved for menu and operating system commands, such as Ctrl+X and Ctrl+V for standard Windows cut-and-paste, Alt+F4 to close the application window, etc. These and other common shortcut key combinations will not cause a control’s key event to fire.