Skip to content

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

@xoofx

Description

@xoofx

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions