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

Support for Alt+key #93

Open
k-bx opened this Issue Jan 6, 2017 · 22 comments

Comments

Projects
None yet
@k-bx

k-bx commented Jan 6, 2017

I'm actually on macOS and not sure how to correctly describe the issue from technical side.

When in terminal, you can go forward/backward by pressing ctrl+f/ctrl+b and it works in Alacritty, and usually you can jump between words by pressing alt(option)+f/alt(option)+b, but it doesn't work right now.

@rspeer

This comment has been minimized.

Show comment
Hide comment
@rspeer

rspeer Jan 6, 2017

I don't know if this is relevant, but I notice that on Linux, alt+Left and alt+Right are working for me, and serving their purpose of switching windows in tmux. Does macOS's Option key send a different key code?

rspeer commented Jan 6, 2017

I don't know if this is relevant, but I notice that on Linux, alt+Left and alt+Right are working for me, and serving their purpose of switching windows in tmux. Does macOS's Option key send a different key code?

@dannydulai

This comment has been minimized.

Show comment
Hide comment
@dannydulai

dannydulai Jan 7, 2017

Contributor

I use alt-hjkl in vim, so I found this limiting as well.

I solved it by adding this to my config:

  - { key: J,        mods: Alt,     chars: "\x1bj"                       }
  - { key: K,        mods: Alt,     chars: "\x1bk"                       }
  - { key: H,        mods: Alt,     chars: "\x1bh"                       }
  - { key: L,        mods: Alt,     chars: "\x1bl"                       }

I guess all these should be added to the default config file.

Contributor

dannydulai commented Jan 7, 2017

I use alt-hjkl in vim, so I found this limiting as well.

I solved it by adding this to my config:

  - { key: J,        mods: Alt,     chars: "\x1bj"                       }
  - { key: K,        mods: Alt,     chars: "\x1bk"                       }
  - { key: H,        mods: Alt,     chars: "\x1bh"                       }
  - { key: L,        mods: Alt,     chars: "\x1bl"                       }

I guess all these should be added to the default config file.

@cmyr

This comment has been minimized.

Show comment
Hide comment
@cmyr

cmyr Jan 7, 2017

I'm also seeing alt not being correctly passed on macOS. I have a bunch of alt+key bindings in vim, but also the alt+b / alt+f bash/readline commands don't work.

cmyr commented Jan 7, 2017

I'm also seeing alt not being correctly passed on macOS. I have a bunch of alt+key bindings in vim, but also the alt+b / alt+f bash/readline commands don't work.

@dannydulai

This comment has been minimized.

Show comment
Hide comment
@dannydulai

dannydulai Jan 8, 2017

Contributor

@cmyr -- did you try my above bindings? they work for me on MacOS.

Contributor

dannydulai commented Jan 8, 2017

@cmyr -- did you try my above bindings? they work for me on MacOS.

jwilm added a commit that referenced this issue Jan 9, 2017

@jwilm

This comment has been minimized.

Show comment
Hide comment
@jwilm

jwilm Jan 9, 2017

Owner

I just pushed a branch alt-key-tester. Would you guys mind trying it without the bindings and sharing the log?

Owner

jwilm commented Jan 9, 2017

I just pushed a branch alt-key-tester. Would you guys mind trying it without the bindings and sharing the log?

@cmyr

This comment has been minimized.

Show comment
Hide comment
@cmyr

cmyr Jan 9, 2017

@dannydulai your config works, thanks!

@jwilm:

Here's the console output for a few alt+keys on your new branch without the binidings. I'm getting the macOS default special characters.

process_key sending "˙"
process_key got string="¬", mods=ALT, key=Some(L)
process_key sending "¬"
process_key got string="∆", mods=ALT, key=Some(J)
process_key sending "∆"
process_key got string="˚", mods=ALT, key=Some(K)
process_key sending "˚"
process_key got string="†", mods=ALT, key=Some(T)
process_key sending "†"
process_key got string="¥", mods=ALT, key=Some(Y)
process_key sending "¥"```

cmyr commented Jan 9, 2017

@dannydulai your config works, thanks!

@jwilm:

Here's the console output for a few alt+keys on your new branch without the binidings. I'm getting the macOS default special characters.

process_key sending "˙"
process_key got string="¬", mods=ALT, key=Some(L)
process_key sending "¬"
process_key got string="∆", mods=ALT, key=Some(J)
process_key sending "∆"
process_key got string="˚", mods=ALT, key=Some(K)
process_key sending "˚"
process_key got string="†", mods=ALT, key=Some(T)
process_key sending "†"
process_key got string="¥", mods=ALT, key=Some(Y)
process_key sending "¥"```
@jwilm

This comment has been minimized.

Show comment
Hide comment
@jwilm

jwilm Jan 9, 2017

Owner

Oh, right... hmm. I can see one easy solution to this, but then you wouldn't be able to send the special characters. Does iTerm not allow you to send those special characters?

Owner

jwilm commented Jan 9, 2017

Oh, right... hmm. I can see one easy solution to this, but then you wouldn't be able to send the special characters. Does iTerm not allow you to send those special characters?

@dannydulai

This comment has been minimized.

Show comment
Hide comment
@dannydulai

dannydulai Jan 9, 2017

Contributor

In Terminal.app, I get the funny chars by default unless, in the keyboard settings for that profile, I turn on the checkbox "Use Option as Meta key". Once I do that, then I see ^[[CHAR

Contributor

dannydulai commented Jan 9, 2017

In Terminal.app, I get the funny chars by default unless, in the keyboard settings for that profile, I turn on the checkbox "Use Option as Meta key". Once I do that, then I see ^[[CHAR

@jwilm

This comment has been minimized.

Show comment
Hide comment
@jwilm

jwilm Jan 9, 2017

Owner

Ah cool; sounds like this is a config issue then.

Owner

jwilm commented Jan 9, 2017

Ah cool; sounds like this is a config issue then.

@jra

This comment has been minimized.

Show comment
Hide comment
@jra

jra Jan 19, 2017

Me too! I want Meta, not the special characters. What is the easy solution? Is there something I can drop into the config file?

jra commented Jan 19, 2017

Me too! I want Meta, not the special characters. What is the easy solution? Is there something I can drop into the config file?

@casey

This comment has been minimized.

Show comment
Hide comment
@casey

casey Feb 20, 2017

Is this issue actually a dupe of #62?

I think that fixing #62 would fix this, although I may be missing something.

casey commented Feb 20, 2017

Is this issue actually a dupe of #62?

I think that fixing #62 would fix this, although I may be missing something.

@rafi

This comment has been minimized.

Show comment
Hide comment
@rafi

rafi Feb 20, 2017

Has anyone been able to map Ctrl+6? I use it a lot in Vim but am not able to use it with Alacritty. I've tried:

- { key: Key6,     mods: Control, chars: "\x1b[27;5;54~" }

rafi commented Feb 20, 2017

Has anyone been able to map Ctrl+6? I use it a lot in Vim but am not able to use it with Alacritty. I've tried:

- { key: Key6,     mods: Control, chars: "\x1b[27;5;54~" }
@joshuarubin

This comment has been minimized.

Show comment
Hide comment
@joshuarubin

joshuarubin Mar 28, 2017

I am able to use the Alt key (MacOS) with a line like:

{ key: P,  mods: Alt,           chars: "\x1bp"                       }

However, using the Alt key without an explicit mapping like that, e.g. <alt>i, causes Alacritty to peg the cpu to 100% and become unresponsive.

joshuarubin commented Mar 28, 2017

I am able to use the Alt key (MacOS) with a line like:

{ key: P,  mods: Alt,           chars: "\x1bp"                       }

However, using the Alt key without an explicit mapping like that, e.g. <alt>i, causes Alacritty to peg the cpu to 100% and become unresponsive.

@nanzhong

This comment has been minimized.

Show comment
Hide comment
@nanzhong

nanzhong Jun 7, 2017

Similar to what @dannydulai suggested, if you use a different keyboard layout (eg. dvorak) you will need to map the keys to their qwerty equivalent.

For dvorak:

  - { key: N,        mods: Alt,     chars: "\x1bb"                       }
  - { key: Y,        mods: Alt,     chars: "\x1bf"                       }

nanzhong commented Jun 7, 2017

Similar to what @dannydulai suggested, if you use a different keyboard layout (eg. dvorak) you will need to map the keys to their qwerty equivalent.

For dvorak:

  - { key: N,        mods: Alt,     chars: "\x1bb"                       }
  - { key: Y,        mods: Alt,     chars: "\x1bf"                       }
@lambdalisue

This comment has been minimized.

Show comment
Hide comment
@lambdalisue

lambdalisue Jul 4, 2017

@rafi

  - { key: Key6,     mods: Control, chars: "\x1e"                        }

Works for me on macOS.

lambdalisue commented Jul 4, 2017

@rafi

  - { key: Key6,     mods: Control, chars: "\x1e"                        }

Works for me on macOS.

@jedahan

This comment has been minimized.

Show comment
Hide comment
@jedahan

jedahan Oct 6, 2017

With latest alacritty and tmux, I finally got forward and backward movement with the following:

- { key: F,  mods: Alt,           chars: "\x1bf"                       }
- { key: B,  mods: Alt,           chars: "\x1bb"                       }

jedahan commented Oct 6, 2017

With latest alacritty and tmux, I finally got forward and backward movement with the following:

- { key: F,  mods: Alt,           chars: "\x1bf"                       }
- { key: B,  mods: Alt,           chars: "\x1bb"                       }
@meain

This comment has been minimized.

Show comment
Hide comment
@meain

meain Nov 2, 2017

How to add alt + number keymaps?

meain commented Nov 2, 2017

How to add alt + number keymaps?

@yqrashawn

This comment has been minimized.

Show comment
Hide comment
@yqrashawn

yqrashawn Dec 22, 2017

@meain I solved by adding these configurations.

  - { key: Key0, mods: Alt, chars: "\x1b0" }
  - { key: Key1, mods: Alt, chars: "\x1b1" }
  - { key: Key2, mods: Alt, chars: "\x1b2" }
  - { key: Key3, mods: Alt, chars: "\x1b3" }
  - { key: Key4, mods: Alt, chars: "\x1b4" }
  - { key: Key5, mods: Alt, chars: "\x1b5" }
  - { key: Key6, mods: Alt, chars: "\x1b6" }
  - { key: Key7, mods: Alt, chars: "\x1b7" }
  - { key: Key8, mods: Alt, chars: "\x1b8" }
  - { key: Key9, mods: Alt, chars: "\x1b9" }

yqrashawn commented Dec 22, 2017

@meain I solved by adding these configurations.

  - { key: Key0, mods: Alt, chars: "\x1b0" }
  - { key: Key1, mods: Alt, chars: "\x1b1" }
  - { key: Key2, mods: Alt, chars: "\x1b2" }
  - { key: Key3, mods: Alt, chars: "\x1b3" }
  - { key: Key4, mods: Alt, chars: "\x1b4" }
  - { key: Key5, mods: Alt, chars: "\x1b5" }
  - { key: Key6, mods: Alt, chars: "\x1b6" }
  - { key: Key7, mods: Alt, chars: "\x1b7" }
  - { key: Key8, mods: Alt, chars: "\x1b8" }
  - { key: Key9, mods: Alt, chars: "\x1b9" }
@meain

This comment has been minimized.

Show comment
Hide comment
@meain

meain Dec 22, 2017

That works, thank you @yqrashawn

meain commented Dec 22, 2017

That works, thank you @yqrashawn

@radiosilence

This comment has been minimized.

Show comment
Hide comment
@radiosilence

radiosilence May 2, 2018

On macOS do this:

  - { key: Up,       mods: Alt,     chars: "\x1b[1;5A"                   }
  - { key: Down,     mods: Alt,     chars: "\x1b[1;5B"                   }
  - { key: Left,     mods: Alt,     chars: "\x1bb"                       }
  - { key: Right,    mods: Alt,     chars: "\x1bf"                       }
  - { key: Key0,     mods: Alt,     chars: "º"                           }
  - { key: Key1,     mods: Alt,     chars: "¡"                           }
  - { key: Key2,     mods: Alt,     chars: "€"                           }
  - { key: Key3,     mods: Alt,     chars: "#"                           }
  - { key: Key4,     mods: Alt,     chars: "¢"                           }
  - { key: Key5,     mods: Alt,     chars: "∞"                           }
  - { key: Key6,     mods: Alt,     chars: "§"                           }
  - { key: Key7,     mods: Alt,     chars: "¶"                           }
  - { key: Key8,     mods: Alt,     chars: "•"                           }
  - { key: Key9,     mods: Alt,     chars: "ª"                           }

radiosilence commented May 2, 2018

On macOS do this:

  - { key: Up,       mods: Alt,     chars: "\x1b[1;5A"                   }
  - { key: Down,     mods: Alt,     chars: "\x1b[1;5B"                   }
  - { key: Left,     mods: Alt,     chars: "\x1bb"                       }
  - { key: Right,    mods: Alt,     chars: "\x1bf"                       }
  - { key: Key0,     mods: Alt,     chars: "º"                           }
  - { key: Key1,     mods: Alt,     chars: "¡"                           }
  - { key: Key2,     mods: Alt,     chars: "€"                           }
  - { key: Key3,     mods: Alt,     chars: "#"                           }
  - { key: Key4,     mods: Alt,     chars: "¢"                           }
  - { key: Key5,     mods: Alt,     chars: "∞"                           }
  - { key: Key6,     mods: Alt,     chars: "§"                           }
  - { key: Key7,     mods: Alt,     chars: "¶"                           }
  - { key: Key8,     mods: Alt,     chars: "•"                           }
  - { key: Key9,     mods: Alt,     chars: "ª"                           }
@frontsideair

This comment has been minimized.

Show comment
Hide comment
@frontsideair

frontsideair May 17, 2018

@jedahan your solution worked for me, since you're the author would you like to make a PR to add it to default config? If you'd rather not, I can do it. Thanks!

frontsideair commented May 17, 2018

@jedahan your solution worked for me, since you're the author would you like to make a PR to add it to default config? If you'd rather not, I can do it. Thanks!

@justinmk

This comment has been minimized.

Show comment
Hide comment
@justinmk

justinmk May 17, 2018

For reference, kitty solved this in core, avoiding the need for hacky mappings: https://github.com/kovidgoyal/kitty/search?q=alt+macos&type=Commits

justinmk commented May 17, 2018

For reference, kitty solved this in core, avoiding the need for hacky mappings: https://github.com/kovidgoyal/kitty/search?q=alt+macos&type=Commits

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