To handle keyboard input in code on a form level, even if a control on the form currently has the focus, simply set the KeyPreview
property of the form to true
.
This configures that the form will receive key events before the event is passed to the control that has focus.