Repository navigation
Closed
Labels
Resolution-ExternalThe issue is caused by external component(s).WG-Interactive-Consolethe console experience
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
After upgrading from 7.1.5 to 7.2.0 on Linux, both $Host.UI.RawUI.ReadKey() and [Console]::ReadKey() functions return keycode 27 (ESC) when any of the arrow keys are pressed.
Expected behavior
$host.UI.RawUI.ReadKey()
VirtualKeyCode Character ControlKeyState KeyDown
-------------- --------- --------------- -------
37 0 True
When arrow key left is pressed; other arrows produce codes 38,39,40Actual behavior
---clip---
$host.UI.RawUI.ReadKey()
VirtualKeyCode Character ControlKeyState KeyDown
-------------- --------- --------------- -------
27 0 True
---clap---
When any of the four arrow keys is pressed, result is always above.
Additionally, character 'A' is typed on next cmdline when up arrow is pressed, other arrows type chars C,B,D:
---clip---
PS > $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
VirtualKeyCode Character ControlKeyState KeyDown
-------------- --------- --------------- -------
27 [0m 0 True
PS > A
---clap---
Pressing enter produces result as if I had typed the 'A' myself:
---clip---
A: The term 'A' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
---clap---
ReadKey() argument "NoEcho" has no effect on above behaviour.
Finally, the problem is not reproducible when running a powershell script from another shell. Executing script below from
either bash or zsh produces correct result, but executing from pwsh does not.
---clip---
#!/usr/bin/pwsh
$host.UI.RawUI.ReadKey()
---clap---Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.2.0
PSEdition Core
GitCommitId 7.2.0
OS Linux 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03)
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Reacted by maccluu
Metadata
Metadata
Assignees
Labels
Resolution-ExternalThe issue is caused by external component(s).WG-Interactive-Consolethe console experience
Activity
ScoutmanPt commentedon Jan 24, 2022
Howdy , any update on this?
oranki commentedon Mar 2, 2022
Issue is still present in version 7.2.1.
mark-hubers commentedon May 21, 2022
Still a problem in version 7.2.4.
mark-hubers commentedon May 23, 2022
I cannot wait for this so I made a hack around this problem for now. Hope it help others as I need to be able to use up and down arrow on Linux/Mac for a console menu.
Read up/down keys on *nix properly - fixes #11
daxian-dbw commentedon Sep 8, 2022
Opened dotnet/runtime#75305 to ask for insights and clarification.
daxian-dbw commentedon Sep 16, 2022
This was resolved in .NET 7-RC.1 release. The screenshot below is PowerShell built against .NET 7-RC.1 running on Ubuntu WSL2.