-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Console.ReadKey] Return the correct KeyChar on Alt+Symbol chords #39539
[Console.ReadKey] Return the correct KeyChar on Alt+Symbol chords #39539
Conversation
Tagging subscribers to this area: @eiriktsarpalis |
c1db0a5
to
feda909
Compare
feda909
to
faeba85
Compare
faeba85
to
727d5b6
Compare
Could I get some feedback on this PR? It's unlikely it will make it for 5.0 but if people feel it's in the right direction I could maybe try to get it in. |
private bool IsPotentialKeyCharacter(char keyChar) | ||
{ | ||
// symbol or punctuation ascii characters | ||
return keyChar < '\x0080' && (char.IsSymbol(keyChar) || char.IsPunctuation(keyChar)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to suggest char.IsAscii(char)
but it's private for some reason (don't know why, seems like a reasonable API). There is Rune.IsAscii(keyChar)
but I think that's less readable 😐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps something we could make public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushing to 6.0 |
727d5b6
to
5c10193
Compare
@eiriktsarpalis are you still working on this? or can you close the PR? |
Not actively working on this at the moment. I think we should just close. |
Contributes to #802.
Attempts to address an issue on Unix where using
Console.ReadKey()
to read Alt + symbol chords will return the Escape character. For example:The current behaviour is by design, escape is returned whenever the trailing character cannot be conclusively mapped to a keychord. However this often results in loss of information in otherwise legal key chords.
This PR adds a conservative change, where if the trailing character is an ASCII symbol, then that character will be returned instead of Escape:
Note that this change will still drop valid keychords (e.g. Alt + £ in UK keyboard layouts).
Should be merged after #39460.