KeyDown event key combination in WPF textbox

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.