Skip to content

Alt arrow keys print extra characters #3101

Closed

Description

@paulwhiting

Terminal Version: 0.5.2762.0
Microsoft Windows [Version 10.0.18362.356]

Steps to reproduce

Open terminal. Press alt-up, alt-down, alt-right, alt-left.

(For byobu: start byobu with 'byobu'. Press F2 to add a new tab. Press alt-right and alt-left to switch between tabs.)

Expected behavior

Observed behavior

  • c:\windows\system32\bash.exe: ABCD is printed out as expected.
  • c:\windows\system32\bash.exe in byobu: Byobu tabs are switched on alt-left and alt-right. (Only a single session is running so alt-up and alt-down just error out as expected.) No additional characters are printed out, as expected.
  • Windows Powershell terminal (run->powershell): Nothing is printed out. (Expected? I don't know.)
  • Terminal App powershell: ☻♠♦ is printed out.
  • Terminal App ubuntu: A◘B☻C♠D♦ is printed out.
  • Terminal App ubuntu in byobu: Byobu tabs are are switched as expected, BUT when alt is released one of ◘☻♠♦ is printed out depending on which arrow key was pressed last.

Activity

  1. ghost added
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Oct 7, 2019
  2. ghost added
    Needs-Tag-FixDoesn't match tag requirements
    on Oct 7, 2019
  3. rideron89 commented on Oct 7, 2019

    @rideron89

    I'm having the same issue. Happens in both fish and bash.

    I use alt-left and alt-right to navigate through words on a command.

    Terminal version: 0.5.2762.0
    Windows 10 version 18362.388 (1903)

  4. DHowett-MSFT commented on Oct 7, 2019

    @DHowett-MSFT
    Contributor

    Confirmed! Possible regression from #2836 (/cc Leonard Hecker (@lhecker))?

  5. added
    Area-InputRelated to input processing (key presses, mouse, etc.)
    Area-TerminalControlIssues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.)
    Issue-BugIt either shouldn't be doing this or needs an investigation.
    on Oct 7, 2019
  6. ghost removed
    Needs-Tag-FixDoesn't match tag requirements
    on Oct 7, 2019
  7. added
    Needs-Tag-FixDoesn't match tag requirements
    and removed
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Oct 7, 2019
  8. ghost removed
    Needs-Tag-FixDoesn't match tag requirements
    on Oct 7, 2019
  9. lhecker commented on Oct 8, 2019

    @lhecker
    Member

    Dustin L. Howett (MSFT) (@DHowett-MSFT) This issue is caused by the use of ToUnicodeEx(), which has the following warning...

    As ToUnicodeEx translates the virtual-key code, it also changes the state of the kernel-mode keyboard buffer. This state-change affects dead keys, ligatures, alt+numpad key entry, and so on. It might also cause undesired side-effects if used in conjunction with TranslateMessage (which also changes the state of the kernel-mode keyboard buffer).

    I'll open a PR.

    paulwhiting I was not able to exactly replicate your observed behavior. Is there a way to switch between "keypad mode" on/off? I'm "Press[ing] alt-up, alt-down, alt-right, alt-left" (in that order) and I'm not really certain why I'm getting these different results:

    • C:\Windows\System32\bash.exe: Alt+Up/Down causes a beep (or "bing") and Alt+Left/Right jumps between words
    • Terminal App powershell: ◘☻♠♦ is printed out.
    • Terminal App ubuntu: ♦◘☻♠ is printed out.
  10. ghost added
    In-PRThis issue has a related PR
    on Oct 8, 2019
  11. paulwhiting commented on Oct 9, 2019

    @paulwhiting
    Author

    I believe num lock should do what you want? My keyboard doesn't have a numeric keypad, just standalone arrow keys. You're not seeing the ABCD characters because your underlying shell is handling those. It's the extra one of ♦◘☻♠ that pops up after letting go of alt that's the problem.

  12. davy-tw commented on Oct 15, 2019

    @davy-tw

    In my case, the extra keystroke will happens when I "release the Alt key" after pressing Alt+Left/Right/Up/Down.
    If I don't release Alt key, the control key \cA \cB \cC \cD won't come out.

  13. sivaramn commented on Oct 21, 2019

    @sivaramn

    can confirm, I too face this. Within tmux, if i switch panes using Alt+direction keys, i get funny chars on the command line

  14. daveshih01 commented on Nov 13, 2019

    @daveshih01

    Hi folks, sorry for stating the obvious. Please review/approve the PR so this can be addressed. Thanks!

  15. ghost added
    Needs-Tag-FixDoesn't match tag requirements
    on Nov 13, 2019
  16. ghost removed
    In-PRThis issue has a related PR
    on Nov 13, 2019
  17. ghost added
    Resolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.
    on Nov 13, 2019
  18. added a commit that references this issue on Nov 13, 2019
    c9f148c
  19. daveshih01 commented on Nov 14, 2019

    @daveshih01

    Thanks, everyone!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-InputRelated to input processing (key presses, mouse, etc.)Area-TerminalControlIssues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.)Issue-BugIt either shouldn't be doing this or needs an investigation.Needs-Tag-FixDoesn't match tag requirementsProduct-TerminalThe new Windows Terminal.Resolution-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