2023-12-09

Windows terminal is not properly sending ctrl-space, causing problems with tmux and emacs

When using Windows Terminal to connect to a remote workstation, the transmission chain doesn't pass on certain keyboard inputs such as ctrl-space.

Below is a simple illustration of how I understand the transmission chain. The illustration includes the workstation running the command showkey to display any received keyboard codes:

  • Windows laptop
    • Windows Terminal
      • PowerShell
        • SSH client - outputs {keyboard codes}
  • Workstation (Linux)
    • SSH server
      • bash
        • $ showkey -a <- sink of {keyboard codes}

I expect showkey to show the following when I, in sequence, type space, ctrl-space and ctrl-d (to end):

$ showkey -a

Press any keys - Ctrl-D will terminate this program

     32 0040 0x20
^@    0 0000 0x00
^D    4 0004 0x04

However, from Windows Terminal, the result is only:

$ showkey -a

Press any keys - Ctrl-D will terminate this program

     32 0040 0x20
^D    4 0004 0x04

Notice how the line with ^@ ... is missing - the ctrl-space was never received.

The missing keyboard codes causes problems with e.g.:

  • selecting text in Tmux's scrollback buffer (ctrl-space is used for 'begin-selection')
  • begin marking text in Emacs (set-mark-command)

My guess is that the problem relates to Windows Terminal, so I'm looking for suggestions on how to fix it with respect to not sending 'ctrl-space'?

Note: I've tried removing key bindings in Windows Terminal, which took care of some other "blocked" keys, but not ctrl-space.

Note: I don't want to change key bindings for both Tmux and Emacs to work around bugs in Windows Terminal. And on all of the remote workstations...

Should I use another terminal emulator on Windows? (I don't have admin access to my Windows laptop, so it likely needs to be in the Windows Store.)



No comments:

Post a Comment