Skip to content
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 and pressing SHIFT+END returns invalid escape sequence on WSL/Ubuntu #45597

Closed
Tracked by #64487
xoofx opened this issue Dec 4, 2020 · 3 comments · Fixed by #72193
Closed
Tracked by #64487

Console.ReadKey and pressing SHIFT+END returns invalid escape sequence on WSL/Ubuntu #45597

xoofx opened this issue Dec 4, 2020 · 3 comments · Fixed by #72193
Assignees
Milestone

Comments

@xoofx
Copy link
Member

xoofx commented Dec 4, 2020

Description

From the issue in kalk#18

When pressing SHIFT+END with the following program in WSL:

using System;

namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var key = Console.ReadKey(true);
                Console.WriteLine($"Key: {key.Key} Modifiers: {key.Modifiers} Char: {(key.KeyChar < ' ' || (int)key.KeyChar >= 126 ? "0x" + ((int)key.KeyChar).ToString("x2") : key.KeyChar.ToString())}");
            }
        }
    }
}

It generates the following sequence on Linux:

Key: Escape Modifiers: 0 Char: 0x1b
Key: D1 Modifiers: 0 Char: 1
Key: 0 Modifiers: 0 Char: ;
Key: D2 Modifiers: 0 Char: 2
Key: F Modifiers: Shift Char: F

instead of generating the following on Windows:

Key: End Modifiers: Shift Char: 0x00

I don't know if it is a problem in .NET or WSL.

Configuration

Tested on all WSL Ubuntu versions (16.04, 20.04)
Tested with .NET Core App 3.1 and .NET 5.0

Regression?

No, it was already broken with netcoreapp3.1

Other information

No workaround

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Console untriaged New issue has not been triaged by the area owner labels Dec 4, 2020
@ghost
Copy link

ghost commented Dec 4, 2020

Tagging subscribers to this area: @eiriktsarpalis
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

From the issue in kalk#18

When pressing SHIFT+END with the following program in WSL:

using System;

namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var key = Console.ReadKey(true);
                Console.WriteLine($"Key: {key.Key} Modifiers: {key.Modifiers} Char: {(key.KeyChar < ' ' || (int)key.KeyChar >= 126 ? "0x" + ((int)key.KeyChar).ToString("x2") : key.KeyChar.ToString())}");
            }
        }
    }
}

It generates the following sequence on Linux:

Key: Escape Modifiers: 0 Char: 0x1b
Key: D1 Modifiers: 0 Char: 1
Key: 0 Modifiers: 0 Char: ;
Key: D2 Modifiers: 0 Char: 2
Key: F Modifiers: Shift Char: F

instead of generating the following on Windows:

Key: End Modifiers: Shift Char: 0x00

I don't know if it is a problem in .NET or WSL.

Configuration

Tested on all WSL Ubuntu versions (16.04, 20.04)
Tested with .NET Core App 3.1 and .NET 5.0

Regression?

No, it was already broken with netcoreapp3.1

Other information

No workaround

Author: xoofx
Assignees: -
Labels:

area-System.Console, untriaged

Milestone: -

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Dec 4, 2020

Related to #802 and #44621. I can reproduce the issue locally.

@eiriktsarpalis eiriktsarpalis removed the untriaged New issue has not been triaged by the area owner label Dec 4, 2020
@eiriktsarpalis eiriktsarpalis added this to the 6.0.0 milestone Dec 4, 2020
@adamsitnik adamsitnik modified the milestones: 6.0.0, 7.0.0 Jul 26, 2021
@jeffhandley
Copy link
Member

@adamsitnik This might be worth re-testing to see if it gets fixed as part of #802.

@adamsitnik adamsitnik self-assigned this Jul 11, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 14, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 1, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants