Form-level keyboard handling

I have a form with several custom controls that are the main window of my application. I would like to capture all the keystrokes while my application is running, at the form level, and not on focused control or something. What is the standard way to do this in WinForms?

+2


source to share


2 answers


set Form.PreviewKeys = true then you get all keyboard events.



+3


source


Set the Form's KeyPreview property to true and then handle one of the keypress events.



+1


source







All Articles