I need to capture the KeyUp event in my form (to toggle a "full screen mode"). Here's what I'm doing:
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
if (e.KeyCode == Keys.F12) this.ToggleFullScreen();
}
private void ToggleFullScreen()
{
// Snazzy code goes here
}
This works fine, unless a control on the form has focus. In that case, I don't get the event at all (also tried OnKeyDown - no luck there either).
I could handle the KeyUp event from the child control, but the controls on the form are generated dynamically, and there may be many of them - each having many children of their own.
Is there any way to do this without generating event handlers for every control on the screen (which I certainly could do with a recursive function)?