Let System.ConsoleKeyInfo able to represent keypress in the Unicode world #51085
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-System.Console
Milestone
Background and Motivation
The design of keyboard key code and key char is dated back to IBM PC and we have code pages to make things work.
Currently, we have much more complicated keyboards, some of them can type in script languages, some of them can directly input emoji.
But
System.ConsoleKeyInfo
uses achar
to store key char. Which caused a lot of long hanging serious issue:#27828 is only one of the examples.
These problems can be easily fixed by adding a new property.
Proposed API
namespace System { public struct ConsoleKeyInfo { + public ReadOnlySpan<System.Text.Rune> KeyCharacters { get; } }
Usage Examples
Alternative Designs
The property type can also be
ReadOnlySpan<char>
or evenstring
. The name can also be different.Risks
ConsoleKeyInfo
is[Serializable]
.The text was updated successfully, but these errors were encountered: