Live Chat Icon For mobile
Live Chat Icon

How can I listen for certain keys at the Form level irrespective of which Control has the focus?

Platform: WinForms| Category: Keyboard Handling

When the Form.KeyPreview property is set to true, the Form’s KeyPress, KeyDown and KeyUp events will be fired even before the Control with the focus’ corresponding events. You may choose to forward these message to the Control after processing them in the Form’s event handlers (this happens by default) or set the e.Handled property to true (in the event argument) to prevent the message from being sent to the Control with focus.

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.