Share via


KeyPreview Property

Specifies whether a form's KeyPress event intercepts the KeyPress events of a control. Available at design time and run time.

Object.KeyPreview[ = lExpr]

Property Values

  • lExpr
    The settings for the KeyPreview property are:
    Setting Description
    True (.T.) The form receives KeyPress events first and then the active control receives KeyPress events.
    False (.F.) (Default) The active control receives Keypress events; the form doesn't.

Remarks

The KeyPreview property is used to allow the form to handle KeyPress events before the active control processes them.

You can use this property to create a keyboard-handling procedure for a form. For example, when an application uses function keys, you can process the keystrokes at the form level rather than writing code for each control that can receive keystroke events.

If a form has no visible and enabled controls, it automatically receives all keyboard events.

See Also

Enabled Property | KeyPress Event | Visible Property

Applies To: Form | Page | _SCREEN | ToolBar