wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
16.65k stars 745 forks source link

option key not working on mac #5468

Open Morg42 opened 3 months ago

Morg42 commented 3 months ago

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

20240203-110809-5046fc22

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

No, and I'll explain why below

Describe the bug

Typing option- (n, l, 5, 6, 7, 8, 9) does funny things, but doesn't produce the expected char (~, @, [, ], |, {, }).

Typing after option-n doesn't do anything, not obviously a dead key issue.

Tried mainly with left option, but right option does not change things.

Tried use_ime = true, use_ime = false and omitting use_ime altogether.

Disabling zshrc configuration makes left option- a kind of "repeat following key" action (option-7 1 types 1111111, option-3 1 types 111, option-4 space types 4 spaces); right option doesn't do anything

Enabling zshrc makes wezterm ignore input after option- until enter is pressed, not producing output.

To Reproduce

Press and hold option, press one of the mentioned keys (e.g. n), release all keys.

Configuration

-- Pull in the wezterm API local wezterm = require 'wezterm'

-- This will hold the configuration. local config = wezterm.config_builder()

-- This is where you actually apply your config choices

config.use_ime = true

-- and finally, return the configuration to wezterm return config

Also tried use_ime = false and omitting use_ime altogether.

Also tried

keys = { {key="n", mods="OPT", action=wezterm.action{SendString="~"}}, {key="7", mods="OPT", action=wezterm.action{SendString="|"}}, }

with no different result.

Expected Behavior

option-n -> ~ option-l -> @ option-5 -> [ option-6 -> ] option-7 -> | option-8 -> { option-9 -> }

Logs

Debug Overlay wezterm version: 20240203-110809-5046fc22 x86_64-apple-darwin Window Environment: macOS 12.7 (21G816) Lua Version: Lua 5.4 OpenGL: Intel(R) Iris(TM) Graphics 6100 4.1 INTEL-18.8.6 Enter lua statements or expressions and hit Enter. Press ESC or CTRL-D to exit

No further relevant log files.

Anything else?

Tried different solutions from older issues, which are all marked as "solved" or "solved in nightly", most from years 2020 - 2022 to no avail.

Disabling my zshrc completely changed behaviour, see above.

Morg42 commented 3 months ago

Update with latest nightly version 20240520-135708-b8f94c47:

without zshrc: left option key still has no function / option- repeats for times right option key gives all the "right" characters, with exception of option-n for tilde, which is nonfunctional, both as "instant key" as well as "dead key" followed by

with zshrc: left option key does nothing visible, but locks in some strange kind of input mode, only return to "normal" after pressing enter (once or twice, unsure why) right option key does all the right things, except for option-n, which does a visual "cursor left", ignoring all further input. Typing enter executes all the typed command up to option-n, but nothing typed after that.

Now played with the wezterm config, and removing use_dead_keys = false made the right-option-n do a normal "dead key tilde", producing a normal tilde when typing twice or following with a space.

After this, I tried reversing left/right option key with

config.send_composed_key_when_left_alt_is_pressed = true config.send_composed_key_when_right_alt_is_pressed = false

and got "normal" option-combos on left option key, with exception of the dead key tilde.

Not sure how this can be setup in mac, but I've had "nodeadkeys" activated somehow forever, which works just fine in all mac apps including Terminal and iTerm.

Maybe this helps to narrow down this funny behaviour....

Just for reference: this happens independent of selected keyboard layout (at least as far as I checked - german, english, english-pc, english-us, englisch-us-intl pc)

Also for reference:

.zshrc:

DEFAULT_USER="$USER"
setopt auto_pushd
setopt pushd_ignore_dups
unsetopt correct
setopt clobber

expand-or-complete-with-dots() {      # This bunch of code displays red dots when autocompleting
  echo -n "\e[31m......\e[0m"         # a command with the tab key, "Oh-my-zsh"-style.
  zle expand-or-complete
  zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots

(removed stuff like setting path, aliases and the like for clarity; tested with this zshrc -> as described above)

BenjaminHerbert commented 3 months ago

The right option key works for me. The left does not.

Morg42 commented 3 months ago

The right option key works for me. The left does not.

With

config.send_composed_key_when_left_alt_is_pressed = true
config.send_composed_key_when_right_alt_is_pressed = false

you can swap left/right, or set both to true and both "work" - except for my dead key problem...

eBeyond commented 3 months ago

This is a real pain. Without @ or ~ it's hard to work :D

wazum commented 2 months ago
config.send_composed_key_when_left_alt_is_pressed = true
config.send_composed_key_when_right_alt_is_pressed = false

With the settings above I can write a tilde, but I have to press Space afterwards, otherwise it disappears again (MacBook Pro 2021 with German keyboard layout using zsh)

Sulfyderz commented 1 month ago
config.send_composed_key_when_left_alt_is_pressed = true
config.send_composed_key_when_right_alt_is_pressed = false

With the settings above I can write a tilde, but I have to press Space afterwards, otherwise it disappears again (MacBook Pro 2021 with German keyboard layout using zsh)

Yes, the same. In Alacritty or default macOS terminal, you can use right arrow or even ENTER to exit dead keys. I've tried many things to replicate this. Nothing succeed...

patlux commented 1 month ago

Just installed wezterm for the first time and had the same issue on a german keyboard, but config.send_composed_key_when_left_alt_is_pressed = true helped me.

mvillafuertem commented 3 weeks ago

The same thing happens to me on MacOS, the left control key doesn't work either... any hint?

$ wezterm --version

wezterm 20240203-110809-5046fc22
$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 14.6 (23G80)
      Kernel Version: Darwin 23.6.0
Spanish ISO keyboard
sklages commented 3 weeks ago

For me, almost all keys work fine (current MacOS 14.6.1), except '~' .. this solved the issue (for me):

<..>
local act = wezterm.action
config.send_composed_key_when_left_alt_is_pressed = true
config.keys = {
  { key='n', mods='OPT', action=act{SendString="~"} },
}

@ and others work fine out of the box.

Came across wezterm a few days ago, very nice piece of software!

mvillafuertem commented 3 weeks ago

@sklages which version of wezterm are you using? which version of macOS? which keyboard?

sklages commented 3 weeks ago

@mvillafuertem

zzstoatzz commented 1 week ago

in case this helps anyone, i am on macos and I wanted LeftArrow | RightArrow and option to "delete back a word" instead of sending unexpected chars so this is what worked for me

-- fix option key
config.keys = {
    {key="LeftArrow", mods="OPT", action=wezterm.action{SendString="\x1bb"}},
    {key="RightArrow", mods="OPT", action=wezterm.action{SendString="\x1bf"}}
}