Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot define a key handler for Ctrl+B #3817

Closed
3 tasks done
sba923 opened this issue Sep 30, 2023 · 5 comments
Closed
3 tasks done

Cannot define a key handler for Ctrl+B #3817

sba923 opened this issue Sep 30, 2023 · 5 comments
Labels
Issue-Docs It's a documentation issue. Resolution-External

Comments

@sba923
Copy link

sba923 commented Sep 30, 2023

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

N/A

Screenshot

image

Environment data

PS Version: 7.3.7
PS HostName: ConsoleHost
PSReadLine Version: 2.3.3
PSReadLine EditMode: Windows
OS: 10.0.22621.2338 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 9001

Steps to reproduce

Run the code snippet in the second example of https://learn.microsoft.com/en-us/powershell/module/psreadline/set-psreadlinekeyhandler?view=powershell-7.3

Set-PSReadLineKeyHandler -Chord Ctrl+B -ScriptBlock {
    [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
    [Microsoft.PowerShell.PSConsoleReadLine]::Insert('build')
    [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}

Hit Ctrl+B

Expected behavior

build<enter> should be fed to the prompt

(this is what happens e.g. if -Chord F12 is used)

Actual behavior

^B is displayed

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Sep 30, 2023
@daxian-dbw
Copy link
Member

It's a doc issue. It should be Ctrl+b instead of Ctrl+B. I've opened MicrosoftDocs/PowerShell-Docs#10480
Ctrl+B requires pressing Ctrl+Shift+b, and Ctrl+b requires Ctrl+b. A user would expect the latter to work.

@daxian-dbw daxian-dbw added Issue-Docs It's a documentation issue. Resolution-External and removed Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. labels Oct 2, 2023
@sba923
Copy link
Author

sba923 commented Oct 2, 2023

I confirm it works with Ctrl+b.

The documentation states that "as of PSReadLine 2.0.0, the Chord parameter is case-sensitive. Meaning, Ctrl+X and Ctrl+x create different bindings." But it doesn't state that Ctrl+X is interpreted as Ctrl+Shift+x, or that you basically have to use lowercase letters if you want e.g. Ctrl+a to work "as expected."

@daxian-dbw
Copy link
Member

Ctrl+X is literally how you will type this combination -- you need to press Shift+x to produce X.
The doc was updated: MicrosoftDocs/PowerShell-Docs#10483. But if you still see any confusion in the doc, please open a new doc issue.

@sba923
Copy link
Author

sba923 commented Oct 3, 2023

Ctrl+X is literally how you will type this combination -- you need to press Shift+x to produce X.

I'm afraid I cannot concur here. When https://support.microsoft.com/en-us/windows/keyboard-shortcuts-in-windows-dcc61a57-8ff0-cffe-9796-cb9706c75eec tells me to use Ctrl+X for Cut or Ctrl+V for Paste, I don't use the Shift key to perform those operations, and that's just two random examples.

@sba923
Copy link
Author

sba923 commented Oct 6, 2023

Ctrl+X is literally how you will type this combination -- you need to press Shift+x to produce X.

I'm afraid I cannot concur here. When https://support.microsoft.com/en-us/windows/keyboard-shortcuts-in-windows-dcc61a57-8ff0-cffe-9796-cb9706c75eec tells me to use Ctrl+X for Cut or Ctrl+V for Paste, I don't use the Shift key to perform those operations, and that's just two random examples.

I think the new phrasing Letter key references are defined using lowercase letters should suffice--provided users do read the doc 😜.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Docs It's a documentation issue. Resolution-External
Projects
None yet
Development

No branches or pull requests

2 participants