Enter and ALT key combinations
If (e.keystates = = Keyboard.getkeystates (key.return) && keyboard.modifiers = = Modifierkeys.alt) { }
Or
if (e.keystates = = Keyboard.getkeystates (key.return) && (E.keyboarddevice.modifiers & Modifierkeys.control) = = Modifierkeys.control) { }
The Keyboarddevice property also provides the Iskeydown method, the Iskeyup method, the Iskeytoggled method, and the Getkeystates method
For detecting keys with switching functions, you can use the Iskeytoggled () method under the keyboard class to detect
if (E.keyboarddevice.iskeydown (Key.numlock))
{
MessageBox.Show (String. Format ("You pressed the NumLock key, the current state is: {0}", e.keyboarddevice.iskeytoggled (Key.numlock));
}
Easy keyboard information for keyboard events (PREVIEWKEYDOWN,KEYDOWN,PREVIEWKEYUP,KEYUP) to get key combinations and more
1. The KeyEventArgs object contains a Keystates property that reflects the property of the key that triggered the event
2. The Keyboarddevice property provides the same information for all keys on the keyboard, and naturally provides an instance of the Keyboarddevice class. Its properties include which element currently has focus, and which modifier keys (Modifiers) are pressed when the event occurs, including the shift, Ctrl, ALT key, and use bit logic to check their state.
The Keyboarddevice property also provides the Iskeydown method, the Iskeyup method, the Iskeytoggled method, and the Getkeystates method
This article refer to http://www.cnblogs.com/zhuiyi/archive/2012/09/23/2699072.html
KeyDown event key combination in WPF textbox