c# - How do I get the normal characters from a WPF KeyDown event? -


I want the ASCII characters from a code to e.Key from the property KeyDown < / Code> Event

Unfortunately there is no easy way to do this. There are 2 works in it, but they both fall under some circumstances.

The first one is to convert it to a string:

  TestLabel.Content = e.Key.ToString ();  

This will give you things like caps lock and shift etc. But, in the case of alphanumeric keys, it will not tell you the status of change etc. Time, so you have to find out yourself that you are out

The second option is to use TextInput instead, where E. The actual text contained in the text will be included. This will give you the right characters for alphanumeric keys, but this will not give you control letters.


Comments