Skip to content

Console.ReadKey behaves differently in .NET 6 and .NET 7-preview.7 comparing to .NET 5 when TERM is set to rxvt #75289

@daxian-dbw

Description

@daxian-dbw

Description

Description

We got a report in PowerShell repo about "arrow keys not functioning properly in PowerShell 7.2 with rxvt terminals", see PowerShell/PowerShell#16606.

It turns out Console.ReadKey behaves differently in .NET 6 and .NET 7-preview.7 comparing to .NET 5 when TERM is set to rxvt.
In .NET 5, the ConsoleKeyInfo returned for LeftArrow doesn't has any modifiers, as shown below:

image

However, in .NET 6 and .NET 7-preview.7, the ConsoleKeyInfo returned for LeftArrow has Control and Shift modifiers specified, as shown below:

With .NET 6

With .NET 7-preview.7

Note that, this issue was originally reported as #63387, which was closed as completed. However, it's not fixed in .NET 7-preview.7.

Reproduction Steps

  1. Run export TERM=rxvt
  2. Start PowerShell 7.2.0, or 7.2.1, or 7.3.0-preview.7
  3. Try using arrow keys to navigate the cursor position

Expected behavior

LeftArrow and RightArrow should move the cursor left and right;
LeftArrow and RightArrow should go through history commands.

Actual behavior

Arrow keys are not working as expected.
Home and End prints OH and OF respectively.

Regression?

Yes.

Known Workarounds

Setting TERM=xterm would make Console.ReadKey work as expected with rxvt terminals.

Configuration

Which version of .NET is the code running on?
.NET 7-preview.7

What OS and version, and what distro if applicable?
Ubuntu 18.04

What is the architecture (x64, x86, ARM, ARM64)?
x64

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions