PowerShell / PSReadLine

A bash inspired readline implementation for PowerShell
BSD 2-Clause "Simplified" License
3.76k stars 296 forks source link

Pressing FN key puts @ symbol in pwsh console #3757

Closed whitequill closed 1 year ago

whitequill commented 1 year ago

Prerequisites

Steps to reproduce

When I press the Fn (Function) button on the MSI Raider GE76 gamer laptop in Powershell 7.3.4 the key returns an "@" symbol in text output. The Fn Key is used for miscellaneous functions such as, use of the Home,End, Sys Rq keys as well volume up, down and mute; screen brightness up and down; Airplain mode, and all secondary functions on the F-keys.

It's most annoying due to when I want to press the home or end keys a string of "@" symbols appears till I let go of the Function key. I can press and hold the Function key in Notepad and it acts as expected.

The problem does not occur in the Terminal App that can be downloaded from the Windows Store.

Expected behavior

No output when the key is pressed at all.

Actual behavior

PS> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Error details

no errors

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

Powershell

237dmitry commented 1 year ago

I think this is MSI configuration. Try to change key preferences

https://www.msi.com/faq/7427

MSI Global - The Leading Brand in High-end Gaming & Professional Creation
As a world leading gaming brand, MSI is the most trusted name in gaming and eSports. We stand by our principles of breakthroughs in design, and roll out the amazing gaming gear like motherboards, graphics cards, laptops and desktops.
kilasuit commented 1 year ago

I can also repro this on My Lenovo Yoga S730 ( quite an old machine now) so isn't just due to local machine configuration.

@whitequill please can you change the issue title to Pressing FN key puts @ symbol in pwsh console as that's more fitting

kilasuit commented 1 year ago

Also I just tested this and I can only repro it when PSReadline module v2.2.6 is loaded which is bundled with Pwsh 7.3.4 - whether installed as MSI or via the store as MSIX - tested as per the below

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.25393
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
237dmitry commented 1 year ago

Also I just tested this and I can only repro it when PSReadline module is loaded.

What version of PSReadline? I haven't tried 2.3.* yet.

kilasuit commented 1 year ago

@237dmitry updated my comment above - also not tested with 2.3.* versions as of yet

kilasuit commented 1 year ago

Still repros with 2.3.1.beta1 when running in 7.4.0-preview3 when not running in Windows Terminal


Name                             : PSReadLine
Version                          : 2.3.1
$_.PrivateData.PSData.PreRelease : beta1

Name                           Value
----                           -----
PSVersion                      7.4.0-preview.3
PSEdition                      Core
GitCommitId                    7.4.0-preview.3
OS                             Microsoft Windows 10.0.25393
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
237dmitry commented 1 year ago

when not running in Windows Terminal

I tested on three laptops. Two of them with Linux on board and pwsh 7.4.0-preview3, PSReadline 2.2.6 and 2.3.1-beta1. And on a Windows laptop (pwsh 7.3.4, psreadline 2.2.6) and I couldn't reproduce the problem on any of them.

[console]::ReadKey() is not reacted on pressing Fn.

Tilix, alacritty, xfce4-terninal, conhost.exe, Windows Terminal.

sdwheeler commented 1 year ago

@kilasuit What does [console]::ReadKey() show when you press the Fn key?

kilasuit commented 1 year ago

I get this output

image

iSazonov commented 1 year ago

Can you try without PSReadline?

kilasuit commented 1 year ago

We discussed this in the Interactive UX WG this evening and concluded that this is due to an issue in PSReadLine so asking for this issue to be transferred to the PSReadline Repo Specifically, the virtual key is being recorded as VK_NONE & so the scan code is not mapped and therefore PSReadline should ignore it.

daxian-dbw commented 1 year ago

I cannot reproduce the issue with the ThinkPad laptop I have, which has the Fn key on it. I agree this is likely due to the local machine configuration.

microsoft-github-policy-service[bot] commented 1 year ago

This issue is closed because it has been marked as requiring repro steps but has not had any activity for 7 days. If you think the issue is still relevant, please reopen and provide your feedback.

Largelos commented 6 months ago

I have same issue with build-in Windows 2022 powershell during RDP remote sessions, but not reproduced with Windows 2019 or Win10/11.

>$PSVersiontable

Name                           Value
----                           -----
PSVersion                      5.1.20348.2400
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.20348.2400}
BuildVersion                   10.0.20348.2400
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
>Get-Module PSReadline

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.0.0      PSReadline                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Set-PSReadLineOption, PSConsoleHostReadLine}
daxian-dbw commented 6 months ago

@Largelos For what you ran into, I believe it's been fixed in newer versions. Please try upgrading to the latest stable version v2.3.5 and try it out.

Largelos commented 6 months ago

No, reproduced also with v2.3.5. But I'm not sure if this is the PSReadline module issue, because win2019/win10 have same build-in v2.0.0, and FN key doesn't write anything. Also, I reproduce this issue at RDP win11 session too, if run powershell.exe directly, instead of through Windows Console Host (conhost.exe)