[Platform] Raise KeyUp events on focus lost

This ensures that no keys are stuck in pressed state when the user
switches away from the application window.
This commit is contained in:
thefiddler 2014-05-09 01:49:51 +02:00
parent 86146f54d5
commit ab29797079

View file

@ -109,6 +109,20 @@ namespace OpenTK.Platform
protected void OnFocusedChanged(EventArgs e)
{
FocusedChanged(this, e);
if (!Focused)
{
// Clear keyboard state, otherwise KeyUp
// events may be missed resulting in stuck
// keys.
for (Key key = 0; key < Key.LastKey; key++)
{
if (KeyboardState[key])
{
OnKeyUp(key);
}
}
}
}
protected void OnWindowBorderChanged(EventArgs e)