Reputation: 1391
It looks like OnKeyUp
does not fire after the OnKeyPress
event is intercepted in windows forms. I would like to be able to intercept both events. Is that possible?
private void OnKeyPress(object sender, KeyPressEventArgs e)
{
// do something innocuous
}
private void OnKeyUp(object sender, KeyEventArgs e)
{
// do something innocuous
}
Upvotes: 2
Views: 308
Reputation: 69372
Try setting the KeyPreview property of the Form to true
.
When this property is set to true, the form will receive all KeyPress, KeyDown, and KeyUp events.
You can set it in the designer or in code.
public Form1()
{
this.KeyPreview = true;
}
Upvotes: 3