wez / wezterm

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

can't get Alt key to work as Meta #2922

Closed bsferrazza closed 1 year ago

bsferrazza commented 1 year ago

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

Windows

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

No response

WezTerm version

wezterm 20230102-155114-67896f67

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

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

I'm using the current nightly Windows build of WezTerm to connect to my linux workstation. For some reason when I use the Alt key in a program like emacs, it isn't registered as a Meta keypress, much like Esc is. For instance, M-w is the copy command in emacs, and using Alt-w doesn't work. I didn't see any details on the website about configuration options that would correct this issue, and times I've used WezTerm in the past didn't require anything special from what I recall. Below is the debug_key_events output when pressing Alt-w.

To Reproduce

No response

Configuration

local wezterm = require 'wezterm'
return {
    color_scheme = "Gruvbox Dark",
    font = wezterm.font("Hack Nerd Font Mono FC Ligatured CCG"),
    font_size = 12,
    line_height = 1.1,
    default_cursor_style = "BlinkingBar",
    hide_tab_bar_if_only_one_tab = true,
    bypass_mouse_reporting_modifiers = "SHIFT",
    send_composed_key_when_left_alt_is_pressed = true,
    send_composed_key_when_right_alt_is_pressed = true,
    enable_scroll_bar = true
}

Expected Behavior

No response

Logs

15:26:01.772  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event RawKeyEvent { key: Physical(LeftAlt), modifiers: ALT, phys_code: Some(LeftAlt), raw_code: 18, scan_code: 56, repeat_count: 1, key_is_down: true, handled: Handled(false) }
15:26:01.773  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event KeyEvent { key: LeftAlt, modifiers: ALT, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftAlt), modifiers: ALT, phys_code: Some(LeftAlt), raw_code: 18, scan_code: 56, repeat_count: 1, key_is_down: true, handled: Handled(false) }) }
15:26:01.773  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > send to pane DOWN key=LeftAlt mods=ALT
15:26:01.773  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > Encoded input as "\u{1b}[18;56;0;1;2;1_"
15:26:01.987  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event RawKeyEvent { key: Physical(W), modifiers: ALT, phys_code: Some(W), raw_code: 87, scan_code: 17, repeat_count: 1, key_is_down: false, handled: Handled(false) }
15:26:01.989  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event KeyEvent { key: Char('w'), modifiers: ALT, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(W), modifiers: ALT, phys_code: Some(W), raw_code: 87, scan_code: 17, repeat_count: 1, key_is_down: false, handled: Handled(false) }) }
15:26:01.990  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > send to pane UP key=Char('w') mods=ALT
15:26:01.991  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > Encoded input as "\u{1b}[87;17;119;0;2;1_"
15:26:02.004  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event RawKeyEvent { key: Physical(LeftAlt), modifiers: NONE, phys_code: Some(LeftAlt), raw_code: 18, scan_code: 56, repeat_count: 1, key_is_down: false, handled: Handled(false) }
15:26:02.006  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event KeyEvent { key: LeftAlt, modifiers: NONE, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(LeftAlt), modifiers: NONE, phys_code: Some(LeftAlt), raw_code: 18, scan_code: 56, repeat_count: 1, key_is_down: false, handled: Handled(false) }) }
15:26:02.007  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > send to pane UP key=LeftAlt mods=NONE
15:26:02.008  ←[32mINFO  ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > Encoded input as "\u{1b}[18;56;0;0;0;1_"

Anything else?

No response

wez commented 1 year ago

Try changing https://wezfurlong.org/wezterm/config/lua/config/allow_win32_input_mode.html to false

wez commented 1 year ago

Also, either one of send_composed_key_when_left_alt_is_pressed or both of send_composed_key_when_left_alt_is_pressed should be set to false to avoid using the OS alt-gr style composition when using the corresponding alt key, and allow wezterm to encode it as a meta key.

bsferrazza commented 1 year ago

@wez unfortunately that didn't work. I originally wasn't setting the send_composedkey* values and leaving them at the default and it was still not sending Meta. I also tried using no config and setting allow_win32_input_mode to false and that didn't help. Here's the debug_key_presses with that set to false.

18:41:49.191 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent ←[0m > key_event RawKeyEvent { key: Physical(LeftAlt), modifiers: ALT, phys_code: Some(LeftAlt), raw_code: 18, scan_code: 56, repeat_count: 1, key_is_down: true, handled: Handled(false) } 18:41:49.193 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent ←[0m > key_event KeyEvent { key: LeftAlt, modifiers: ALT, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftAlt), modifiers: ALT, phys_code: Some(LeftAlt), raw_code: 18, scan_code: 56, repeat_count: 1, key_is_down: true, handled: Handled(false) }) } 18:41:49.194 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent ←[0m > send to pane DOWN key=LeftAlt mods=ALT 18:41:49.358 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent ←[0m > key_event RawKeyEvent { key: Physical(W), modifiers: ALT, phys_code: Some(W), raw_code: 87, scan_code: 17, repeat_count: 1, key_is_down: false, handled: Handled(false) } 18:41:49.359 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent ←[0m > key_event KeyEvent { key: Char('w'), modifiers: ALT, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(W), modifiers: ALT, phys_code: Some(W), raw_code: 87, scan_code: 17, repeat_count: 1, key_is_down: false, handled: Handled(false) }) } 18:41:49.360 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent ←[0m > send to pane UP key=Char('w') mods=ALT 18:41:49.365 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent ←[0m > key_event RawKeyEvent { key: Physical(LeftAlt), modifiers: NONE, phys_code: Some(LeftAlt), raw_code: 18, scan_code: 56, repeat_count: 1, key_is_down: false, handled: Handled(false) } 18:41:49.366 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent ←[0m > key_event KeyEvent { key: LeftAlt, modifiers: NONE, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(LeftAlt), modifiers: NONE, phys_code: Some(LeftAlt), raw_code: 18, scan_code: 56, repeat_count: 1, key_is_down: false, handled: Handled(false) }) } 18:41:49.377 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent ←[0m > send to pane UP key=LeftAlt mods=NONE

I do use mosh. I'm not sure if that could somehow be contributing to this issue, but doesn't seem as though it would.

wez commented 1 year ago

It looks like wezterm never receives a key down event for alt-w. Do you have some other software installed on the system that handles alt-w, or that might do things when the alt key is pressed?

bsferrazza commented 1 year ago

@wez You were absolutely right. Used a Windows program called HotkeyDetective and found out that Alt-w was being processed by some Dell Display Manager tool. Thanks for your help.

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.