void MainWindow_KeyUp(object sender, KeyEventArgs e) { lock (KeyboardState) { if (KeyboardState.Contains(e.Key)) { KeyboardState.Remove(e.Key); } } }