Search code examples
c#wpfkeyeventargs

How to get pressed char from System.Windows.Input.KeyEventArgs?


I have System.Windows.Input.KeyEventArgs e variable. I want to get real char. For example, i press } button on keyboard. And normally it returns string like oem.. but i want to get } char. How to do ?

[EDIT] I use this in TextBox .


Solution

  • See this post... how to capture the '#' character on different locale keyboards in WPF/C#?

    it has a utility function called GetCharFromKey(Key key) which gets locale specific character from the Key of the Keyboard event args.

    Very useful.