I need to get the numeric values of keyboard keys based on ASCII table .As WPF doesn't have built in solution I have tried several hacks:
1. This one gives only the upper case value.
char res ;
Char.TryParse(e.Key.ToString(),out res);
Debug.WriteLine((int)res);
2 This one ,even though it is listed in many places as possible solution , gives a completely wrong number .
Debug.WriteLine(Convert.ToInt16(e.Key).ToString());
So how do I get both upper and lower case letter ASCII codes from the input in WPF ?
Update
After getting several answers here I want to emphasize my question .I absolutely must get ASCII codes from the input both for lower and upper case.No hard coded char compare or anything like that.I am looking for more generic way.