private void gameWindow_KeyDown(object sender, KeyboardKeyEventArgs e) { if (e.Key == Key.NumLock) numLock = !numLock; else if (e.Key == Key.CapsLock) capsLock = !capsLock; else if (e.Key == Key.ScrollLock) scrollLock = !scrollLock; KeyPress newKeyPress = new KeyPress(e.Key, e.Alt, e.Shift, e.Control, e.IsRepeat, numLock, capsLock, scrollLock); if (keyPress != newKeyPress) keyPress = newKeyPress; }
private void gameWindow_KeyDown(object sender, KeyboardKeyEventArgs e) { if (e.Key == Key.NumLock) { numLock = !numLock; } else if (e.Key == Key.CapsLock) { capsLock = !capsLock; } else if (e.Key == Key.ScrollLock) { scrollLock = !scrollLock; } KeyPress newKeyPress = new KeyPress(e.Key, e.Alt, e.Shift, e.Control, e.IsRepeat, numLock, capsLock, scrollLock); if (keyPress != newKeyPress) { keyPress = newKeyPress; } }
/// <summary> /// Checks to see if a key was pressed. /// </summary> /// <returns>Key Press, null if nothing was pressed.</returns> public KeyPress GetKeyPress() { KeyPress kp = keyPress; keyPress = null; return kp; }