The Key
-property returns a value of the enum ConsoleKey
.
The enum ConsoleKey
has a equivalent for every non-modifier-key (Alt, Shift & Ctrl; see enum ConsoleModifiers
).
Therefor, there are 2 possible signs that can be produced by pressing the key "R".
Another example to illustrate this is when you press 4
in your line of numbers above the keys. This is the ConsoleKey
D4. It can be (see key.KeyChar
) 4
or $
. Also note the property Modifiers
in the ConsoleKeyInfo
-class that shows the pressed modifying key.
See the example below to illustrate it:
var key = Console.ReadKey();//press 4
Console.WriteLine("ConsoleKey: " + key.Key); // D4
Console.WriteLine("Char: " + key.KeyChar); // 4
Console.WriteLine("ConsoleModifier: " + key.Modifiers); // 0
key = Console.ReadKey(); //press shift + 4
Console.WriteLine("ConsoleKey: " + key.Key); // D4
Console.WriteLine("Char: " + key.KeyChar); // $
Console.WriteLine("ConsoleModifier: " + key.Modifiers); // Shift
I've taken some information from MSDN
BTW: I only get "R" when pressing "R" or "r". I'm using C#6 with .Net 4.7. Perhaps you're using some newer or older version where it outputs all possible chars instead of the enum value itself on .ToString()
, like it does @ me.