Skip to content

Console.ReadKey returns unexpected ConsoleKeyInfo when pressing Shift+End in WSL (v2 Ubuntu 20.04) #63644

Description

@daxian-dbw

Description

This affects functionality of PSReadLine: PowerShell/PSReadLine#3126

When pressing Shift+End, [console]::ReadKey($true) returns Escape as the ConsoleKeyInfo value, and triggers the 1;2F input from terminal. This is on WSL v2 with Ubuntu 20.04. The value for environment variable TERM is xterm-256color.

image

Note that, Ctrl+End, Alt+End, Ctrl+Home, Alt+Home, and Shift+Home are all work as expected. For example, Shift+Home returns:

image

Reproduction Steps

  1. Run [console]::ReadKey($true), for example, from PowerShell
  2. Press the keystrokes Shift+End

Expected behavior

The returned ConsoleKeyInfo should be:

KeyChar  Key Modifiers
-------  --- ---------
         End     Shift

Actual behavior

returns Escape as the ConsoleKeyInfo value, and triggers the 1;2F input from terminal.

image

Regression?

Not sure. At least the same behavior is found on .NET 5 as well.

Known Workarounds

Unkown.

Configuration

  1. .NET: this repros on both .NET 6 and .NET 5.
  2. OS: Ubuntu 20.04, WSL v2
  3. Architecture is x64

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions