alacritty icon indicating copy to clipboard operation
alacritty copied to clipboard

key bindings in windows (mapping Ctrl+Space)

Open damnskippy opened this issue 7 years ago • 60 comments

Using alacritty (downloaded from the appveyor link) on windows and have some issues/questions about key bindings.

  1. bash shortcuts using Alt key are not working - is this expected? I added a few mappings to the config file that gets me some of what I most commonly use, but however I still miss several other important ones that I don't know how to map (Alt+. for instance, and others).
    Should this work out of the box, or if not, can a canned list of such mappings be made available for those who might want to add it to their configs optionally. One I sorely miss and don't know how to map is Ctrl+Alt+e which binds to expanding aliases.
  - { key: D,        mods: Alt,     chars: "\x1bd"                       }
  - { key: B,        mods: Alt,     chars: "\x1bb"                       }
  - { key: F,        mods: Alt,     chars: "\x1bf"                       }
  1. In tmux I use Space as my prefix key. set -g prefix C-Space I've tried different things (blindly) in the config file and couldn't get this to work. Any pointers on how to achieve this mapping?

Off topic, but on windows, alacritty doesn't honor any of the command line arguments for me. I've seen other folks refer to using this even on windows, so somehow it is specific to my setup I assume. i.e. if I run alacritty.exe -vvv it spawns the terminal but there is no debug output, or if I do alacritty.exe --help the command just returns without any output.

Thanks!

damnskippy avatar Oct 25 '18 14:10 damnskippy

Thank you @zacps for all the effort you've put into the windows port!

damnskippy avatar Oct 25 '18 14:10 damnskippy

Thanks!

Regarding the console output are you using a build from a7e59d39 or later? There was a change made which should fix console output.

Keybindings are not something I've tested much. I don't know how 'special' actions like expanding aliases are triggered.

It's possible that this might need to wait for https://github.com/jwilm/alacritty/issues/1661, because currently all input to Alacritty has to pass through:

Alacritty => WinPTY => CONHOST(cmd) => Shell(User specified)

And if any part of that chain doesn't understand the input it'll probably just get dropped (CONHOST being the worst offender).

I'd suggest trying these things in a bare wsl prompt to see if they work first, then we can go from there.

zacps avatar Oct 25 '18 22:10 zacps

Not being able to map Control+Space kills me as that's my tmux prefix, and I just cannot get it to work (even in bare wsl). Not sure if this is Windows specific, or if I am just not setting up the mapping correctly. I've tried this to no avail: - { key: Space, mods: Control, chars: "\x00" }

I managed to get Alt+. working using the mapping: - { key: Period, mods: Alt, chars: "\x1b." }

BTW, I moved up to the latest rev from Appveyor and that resolved the console output issue! Thanks again.

damnskippy avatar Oct 26 '18 15:10 damnskippy

Found a few past references to using Ctrl+Space, most of them duped to https://github.com/jwilm/alacritty/issues/99, however the popular solution referenced in there doesn't work for me on Windows, it's the one I referenced above, but I'll include the mapping below again. - { key: Space, mods: Control, chars: "\x00" }

Not sure if this is Windows specific or my setup specific. Would be great if someone can test this out in their setup..

damnskippy avatar Oct 26 '18 17:10 damnskippy

If you can't get it to work in bare wsl it's extremely unlikely we'll be able to solve it in alacritty (Might be worth creating an issue in Microsoft/console).

You're welcome to keep investigating this but I'm probably not going to give it much attention anytime soon.

zacps avatar Oct 27 '18 21:10 zacps

Not sure if it's related, but Alt Gr is not working in Alacritty (eg. can't type @ on Azerty) Works fine in other terminals

fculpo avatar Oct 28 '18 08:10 fculpo

@fculpo See https://github.com/jwilm/alacritty/issues/1681

zacps avatar Oct 28 '18 08:10 zacps

If you can't get it to work in bare wsl it's extremely unlikely we'll be able to solve it in alacritty

I can confirm that this works as expected in cmd and powershell running wsl. i.e. I'm able to set C-Space as my tmux prefix key and it works without any issues.

I assume this is what you were referring to when you say "bare wsl"?

damnskippy avatar Oct 28 '18 16:10 damnskippy

Seems specific to Windows alacritty given https://github.com/jwilm/alacritty/issues/99 seems to resolve for other platform(s). FWIW, pretty easy to repro in a couple of steps:

  1. run tmux in bash
  2. set prefix by doing: tmux set -g prefix C-Space
  3. now type C-space followed by % - this if it works successfully will split the terminal into two vertical panes, otherwise it would enter the % or Space character literally as it does on Windows alacritty.

damnskippy avatar Oct 28 '18 16:10 damnskippy

Ran with --print-events to see what the key press events captured by alacritty. Looks like alacritty is picking up the key presses fine but they're potentially getting dropped on the floor somewhere without getting passed on to bash/tmux? Either that, or the mapping in alacritty.yml is not correct/working.

glutin event: DeviceEvent { device_id: DeviceId(DeviceId(462556243)), event: Key(KeyboardInput { scancode: 29, state: Pressed, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } }) }
glutin event: WindowEvent { window_id: WindowId(WindowId(0x12d0f6e)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 29, state: Pressed, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
glutin event: DeviceEvent { device_id: DeviceId(DeviceId(462556243)), event: Key(KeyboardInput { scancode: 57, state: Pressed, virtual_keycode: Some(Space), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } }) }
glutin event: WindowEvent { window_id: WindowId(WindowId(0x12d0f6e)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 57, state: Pressed, virtual_keycode: Some(Space), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
glutin event: WindowEvent { window_id: WindowId(WindowId(0x12d0f6e)), event: ReceivedCharacter(' ') }
glutin event: Awakened
glutin event: DeviceEvent { device_id: DeviceId(DeviceId(462556243)), event: Key(KeyboardInput { scancode: 57, state: Released, virtual_keycode: Some(Space), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } }) }
glutin event: WindowEvent { window_id: WindowId(WindowId(0x12d0f6e)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 57, state: Released, virtual_keycode: Some(Space), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
glutin event: DeviceEvent { device_id: DeviceId(DeviceId(462556243)), event: Key(KeyboardInput { scancode: 29, state: Released, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } }) }
glutin event: WindowEvent { window_id: WindowId(WindowId(0x12d0f6e)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 29, state: Released, virtual_ke

damnskippy avatar Oct 28 '18 16:10 damnskippy

Still not sure how to map ctrl+space in windows, but closing this issue since there doesn't seem any open action here.

damnskippy avatar Apr 10 '19 16:04 damnskippy

Burned by this on Windows, sad to see this closed. 😭

gaving avatar Jan 07 '20 11:01 gaving

@damnskippy Did you ever happen to solve this issue? Currently having the same problem (but trying to use ctrl+space in Vim rather than in tmux). I see the Ubuntu WSL app handles Ctrl+space fine, as well as WSLtty, but sadly no luck in Ubuntu. Temporary fix for me will be to remap my Ctrl+space in Windows to something else (thankfully I don't use Ctrl+space for much) but far from ideal.

jsinkers avatar Apr 11 '20 08:04 jsinkers

+1. It's a bummer for Emacs users. ctrl+space is the equivalent of v in vim.

Shooooooooo avatar May 05 '20 08:05 Shooooooooo

Indeed ! So sad C-Space does not work since in emacs its such an important key combination... I wish it would work so I would not be forced to use microsoft terminal.

pmhoudry avatar May 15 '20 03:05 pmhoudry

Could we get this issue reopened please? ctrl+space is working fine in wsl, with windows terminal, powershell, and cmd.exe.

sudonym1 avatar Jul 01 '20 19:07 sudonym1

Show us alacritty --print-events when you press ctrl + space? In general we can't do much about issues on Windows, since it's not up to us, but up to WinPty/Conpty.

kchibisov avatar Jul 01 '20 20:07 kchibisov

Alacritty-14440.log

In the above I pressed ctrl+space, ctrl+c, ctrl+d

Thanks for taking a look.

sudonym1 avatar Jul 01 '20 21:07 sudonym1

https://github.com/alacritty/alacritty/issues/1703#issuecomment-433476493 User damnskippy's comment above worked for me with Alacritty on Win10. In case it's relevant, I'm launching Alacritty into WSL with

shell:
  program: bash
  args:
    - -c tmux

For the lazy, damnskippy's fix was this: - { key: Space, mods: Control, chars: "\x00" }

I also see some mentions of configuring tmux like

set -g prefix C-Space
unbind C-Space
bind C-Space send-prefix

That middle "unbind" line is new to me, and may or may not be important for your setup.

Just in case there's some other mystery config I have interacting with this that I'm not aware of, all my configs are here: https://github.com/Akaito/configfiles

Akaito avatar Jul 14 '20 16:07 Akaito

Today I changed my shell on a remote server to ZSH (probably not related but that was the last thing I did) and my Control-Space binding completely stopped working. I tried to apply damnskippy's fix but to no avail. In fact, it would seem that Alacritty is not detecting anything when I press Control-Space. I can change the chars in that fix to any sequence of characters, but no matter what I do, pressing Control-Space just yields ^\ in the terminal.

I have alacritty running with shell.program: wsl. The keybinding works with no issues or configuration whatsoever when I try it in the default WSL terminal.

I cannot run alacritty --print-events as it errors out with Failed to initalize any backend!.

I am truly at a loss as to how this started happening, but I can provide any relevant info if needed.

zacharied avatar Aug 03 '20 23:08 zacharied

Ctrl + Space is not getting passed for me.

Host: Windows

ssh'ing to ubuntu vm, shell is bash and the mapping shown in previous post makes no difference. showkey -a doesn't show anything being pressed

sharksforarms avatar Aug 07 '20 04:08 sharksforarms

This is broken, the fix does not work for me either. The interesting thing is the exact same setup / configurations work perfectly fine with the latest Windows Terminal so it's surely something in Alacritty itself.

dhruvasagar avatar Aug 07 '20 05:08 dhruvasagar

If Alacritty's output contains ReceivedCharacter('\u{0}') when running alacritty --print-events | grep "ReceivedCharacter", then this is a Windows bug.

If it doesn't contain that for you, please let me know.

chrisduerr avatar Aug 07 '20 09:08 chrisduerr

I am getting the following when doing Control + Space:

[2020-08-07 09:42:46.458983200] [INFO] glutin event: WindowEvent { window_id: WindowId(WindowId(0x620714)), event: ReceivedCharacter(' ') }

sharksforarms avatar Aug 07 '20 13:08 sharksforarms

@sharksforarms Looks like it should just print a space for you?

chrisduerr avatar Aug 07 '20 14:08 chrisduerr

@davidhewitt / @cole-h could you confirm this? Does Alacritty not receive the correct character here?

chrisduerr avatar Aug 07 '20 14:08 chrisduerr

@chris-morgan @ShalokShalom It is actually just printing a space, and I also have the same logs.

dhruvasagar avatar Aug 07 '20 14:08 dhruvasagar

If I bind C-Space to send "\x00", it not work:

D:\>xxd -psd
a        # press ctrl-space, a, enter
610d0a

But if I bind C-Space to send "\x02" (i.e. C-b), it works:

D:\>xxd -psd
^Ba      # press ctrl-space, a, enter
02610d0a

A workaround for tmux: use C-b as tmux's prefix key and bind C-Space to "\x02" in alacritty.

MoZhonghua avatar Oct 10 '20 01:10 MoZhonghua

@chris-morgan @ShalokShalom It is actually just printing a space, and I also have the same logs.

What do I have to do with it?

ShalokShalom avatar Oct 11 '20 09:10 ShalokShalom

I'd assume this was intended for sharksforarms.

chrisduerr avatar Oct 11 '20 16:10 chrisduerr