Skip to content

Shift+Enter always submits, breaking PSReadline features [Windows.Terminal] #530

Closed

Description

@Jaykul
  • Your Windows build number: (Type ver at a Windows Command Prompt)
Microsoft Windows [Version 10.0.18362.86]
  • What you're doing and what's happening: (Copy & paste specific commands and their output, or include screen shots)

Trying to add an empty line in a multi-line input by pressing Shift + Enter with PSReadline in PowerShell

  • What's wrong / what should be happening instead:

Shift+Enter is treated as Enter, and it tries to run my incomplete command line

Activity

  1. added
    Area-VTVirtual Terminal sequence support
    Product-ConptyFor console issues specifically related to conpty
    Issue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.
    on May 7, 2019
  2. zadjii-msft commented on May 7, 2019

    @zadjii-msft
    Member

    So I'm not sure this is fixable without a lot of work.

    Because the Windows Terminal is using ConPTY as a backend, we can only send keypresses to the attached client app that are encodable by VT sequences. Unfortunately, there's no way to differentiate between Enter and Shift+Enter with just VT.

    So, we need to add support for encoding entire INPUT_RECORDs as VT sequences. Then add support to conpty (in InputStatemachineEngine.*) for parsing such an input record. Then we need to enable the terminal to tell conpty that it should expect such a type of input sequences, and the terminal needs to be able to synthesize them.

    It's something that's doable, but not without at least a weeks worth of work, not including testing.

  3. Jaykul commented on May 8, 2019

    @Jaykul
    ContributorAuthor

    Ouch. Didn't even think of that.

    At least in PSReadLine it's settable, so I will just have to try to learn to use Ctrl+Enter instead
    ... that seems to send a linefeed instead of a carriage return, so it's detectable.

    There's probably a bigger picture here about helping those of us who aren't used to VT learn which combinations just aren't going to work...

  4. pingzing commented on May 17, 2019

    @pingzing
    Contributor

    This actually seems to be a bit of a broader problem--a lot of PSReadLine hotkeys that use Ctrl+ chords don't work either. Ctrl+Space and Ctrl+. come to mind as well.

    EDIT: Interestingly, it seems similar to the issue experienced by xterm.js-based terminal emulators on Windows, as noted in the PSReadLine repo: PowerShell/PSReadLine#877 Ctrl+. is interpreted as Ctrl+@ in the Windows Terminal as well, for example. At a guess, because xterm.js on Windows uses WinPTY which does a pretty similar thing to ConPTY's VT processing?

  5. flxflx commented on Jun 25, 2019

    @flxflx

    The issue seems to prevent the typing of certain characters on non-US keyboard layouts. For example, I cannot type backspace (alt-gr+?) on my German keyboard. This makes Terminal pretty much unusable for me.

  6. krokofant commented on Dec 5, 2019

    @krokofant

    Any known workaround for this?

  7. herolover commented on Dec 23, 2019

    @herolover

    It's really important. In Far I can't open a windows explorer by pressing shift+enter, or call a context menu by pressing a corresponding key of keyboard.

  8. Jaykul commented on Dec 24, 2019

    @Jaykul
    ContributorAuthor

    I think the workaround is to use different hotkeys or different (VT-capable) apps.

    The bottom line is that Windows Terminal is a Terminal Emulator, and both it and ConPTY are inherently limited by (really ancient) standards. I'm almost positive that "we" (the community of Windows users?) don't want to simultaneously "embrace and extend" those standards 😉

    I still think the best solution is just education about what key combinations can't be encoded ...

  9. 7 remaining items

  10. ghost removed
    In-PRThis issue has a related PR
    on Jun 8, 2020
  11. ghost added
    Resolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.
    on Jun 8, 2020
  12. added a commit that references this issue on Sep 5, 2020
    0b3beb7
  13. zsimic commented on Jan 7, 2021

    @zsimic

    I noticed that latest 1.4.3243.0 seems to still be sending (as observed with showkey -a in an ubuntu wsl2 session):

    • 0x0d for enter
    • 0x0d also for shift+enter
    • 0x0a for ctrl+enter
    • nothing for ctrl+shift+enter

    I worked around it by adding these actions to my settings.json:

    { "command": {"action": "sendInput", "input": "\u001b[13;2u" }, "keys": "shift+enter" },
    { "command": {"action": "sendInput", "input": "\u001b[13;5u" }, "keys": "ctrl+enter" },
    { "command": {"action": "sendInput", "input": "\u001b[13;6u" }, "keys": "ctrl+shift+enter" },
    

    And similarly for shift+space:

    { "command": {"action": "sendInput", "input": "\u001b[32;2u" }, "keys": "shift+space" },
    { "command": {"action": "sendInput", "input": "\u001b[32;5u" }, "keys": "ctrl+space" },
    { "command": {"action": "sendInput", "input": "\u001b[32;6u" }, "keys": "ctrl+shift+space" },
    
  14. adouzzy commented on Aug 4, 2021

    @adouzzy

    I worked around it by adding these actions to my settings.json:

    { "command": {"action": "sendInput", "input": "\u001b[13;2u" }, "keys": "shift+enter" },
    { "command": {"action": "sendInput", "input": "\u001b[13;5u" }, "keys": "ctrl+enter" },
    { "command": {"action": "sendInput", "input": "\u001b[13;6u" }, "keys": "ctrl+shift+enter" },
    

    This is gold.
    with https://www.asciitable.com/ , you can set any combination on shortcuts.
    My emacs is flying in the terminal now.
    Huge thanks!

  15. jbsilva commented on Apr 4, 2023

    @jbsilva

    Same problem still happening in 2023 in Version: 1.12.10983.0.

    { "command": {"action": "sendInput", "input": "\u001b[13;2u" }, "keys": "shift+enter" },
    { "command": {"action": "sendInput", "input": "\u001b[13;5u" }, "keys": "ctrl+enter" },
    { "command": {"action": "sendInput", "input": "\u001b[13;6u" }, "keys": "ctrl+shift+enter" },

    This worked for me.

  16. CervEdin commented on Apr 5, 2023

    @CervEdin

    I noticed that latest 1.4.3243.0 seems to still be sending (as observed with showkey -a in an ubuntu wsl2 session):

    * `0x0d` for `enter`
    
    * `0x0d` also for `shift+enter`
    
    * `0x0a` for `ctrl+enter`
    
    * nothing for `ctrl+shift+enter`
    

    I worked around it by adding these actions to my settings.json:

    { "command": {"action": "sendInput", "input": "\u001b[13;2u" }, "keys": "shift+enter" },
    { "command": {"action": "sendInput", "input": "\u001b[13;5u" }, "keys": "ctrl+enter" },
    { "command": {"action": "sendInput", "input": "\u001b[13;6u" }, "keys": "ctrl+shift+enter" },
    

    And similarly for shift+space:

    { "command": {"action": "sendInput", "input": "\u001b[32;2u" }, "keys": "shift+space" },
    { "command": {"action": "sendInput", "input": "\u001b[32;5u" }, "keys": "ctrl+space" },
    { "command": {"action": "sendInput", "input": "\u001b[32;6u" }, "keys": "ctrl+shift+space" },
    

    I did this but then I started getting ;2u instead of space when lingering on the shift key while pressing space. Excluding shift + space did the trick.

  17. revoconner commented on Nov 25, 2025

    @revoconner
    ; Sends Ctrl+Shift+Enter when Claude Code is active, otherwise normal Shift+Enter
    
    #Persistent
    #SingleInstance force
    
    ; Shift+Enter hotkey
    +Enter::
        WinGet, activeProcess, ProcessName, A
        WinGetTitle, activeTitle, A
    
        ; Check if Windows Terminal with Claude Code (title starts with U+2733)
        if (activeProcess = "WindowsTerminal.exe" && SubStr(activeTitle, 1, 1) = Chr(0x2733))
        {
            ; Claude Code is active - send Ctrl+Shift+Enter
            Send ^+{Enter}
        }
        else
        {
            ; Not Claude Code - pass through normal Shift+Enter
            Send +{Enter}
        }
    return

    I use this AHK script to send ctrl+shift+enter when I send shift+enter if the active window is WindowsTerminal.exe and has the claude code unicode character in it - U+2733

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area-InputRelated to input processing (key presses, mouse, etc.)Area-VTVirtual Terminal sequence supportIssue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.Product-ConptyFor console issues specifically related to conptyResolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions