Shortcuts with `Shift` + another modifier + `3` will be ignored when default keybindings are disabled
What Operating System(s) are you seeing this problem on?
Linux X11
Which Wayland compositor or X11 Window manager(s) are you using?
X11 with KWin (5.18.6)
WezTerm version
20241015-083151-9ddca7bd
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 want to create a shortcut Shift+Ctrl+3 to switch to the third tab. But instead the character # is emitted and my config is ignored.
This also happens with Shift+Super+3 and Shift+Ctrl+Super+3. No matter, if I use the left or right Shift or Super key. With Ctrl_R or Alt_R other charcters apper (£, ³ and §), but this should be the correct behaviour as I use a german layout.
Nevertheless, I want to create my own shortcut on e.g. Shift+Ctrl+3 and this will be ignored.
I figured out so far, that this only occurs, when I disable default key bindings with config.disable_default_key_bindings = true. When I remove this line, my mapping works fine.
To Reproduce
Just put the config.disable_default_key_bindings = true to the config and use e.g. Shift+Ctrl+3. This emits the #.
Configuration
local wezterm = require 'wezterm'
local config = wezterm.config_builder()
-- Keybindings
config.disable_default_key_bindings = true
-- it does not matter if here are own keybindings or not e.g.:
-- config.keys = { { key = '3', mods = 'SHIFT|CTRL', action = act.ActivateTab(2) }, -- for numpad 3 (works fine)
-- { key = '§', mods = 'SHIFT|CTRL', action = act.ActivateTab(2) }} -- for other 3 (with § in german layout)
return config
Expected Behavior
Switch to the third tab when I type Shift+Ctrl+3
Logs
No response
Anything else?
No response
Please try to run wezterm from wezterm (or another terminal), with config.debug_key_events = true, to check what Wezterm detects when you press those keys
I started it with wezterm --config debug_key_events=true and got the following output:
$ wezterm --config debug_key_events=true
13:56:57.241 WARN window::os::x11::connection > Unable to resolve appearance using xdg-desktop-portal: get_appearance.read_setting: Reading xdg-portal org.freedesktop.appearance color-scheme: org.freedesktop.portal.Error.NotFound: Requested setting not found
13:57:00.123 INFO wezterm_gui::termwindow::keyevent > key_event RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, leds: (empty), phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) }
13:57:00.123 INFO wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: LeftControl, modifiers: NONE, leds: (empty), repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, leds: (empty), phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) }) }
13:57:00.123 INFO wezterm_gui::termwindow::keyevent > send to pane DOWN key=LeftControl mods=NONE
13:57:00.355 INFO wezterm_gui::termwindow::keyevent > key_event RawKeyEvent { key: Physical(LeftShift), modifiers: CTRL, leds: (empty), phys_code: Some(LeftShift), raw_code: 50, repeat_count: 1, key_is_down: true, handled: Handled(false) }
13:57:00.355 INFO wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: LeftShift, modifiers: CTRL, leds: (empty), repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftShift), modifiers: CTRL, leds: (empty), phys_code: Some(LeftShift), raw_code: 50, repeat_count: 1, key_is_down: true, handled: Handled(false) }) }
13:57:00.355 INFO wezterm_gui::termwindow::keyevent > send to pane DOWN key=LeftShift mods=CTRL
13:57:01.011 INFO wezterm_gui::termwindow::keyevent > key_event RawKeyEvent { key: Physical(K3), modifiers: SHIFT | CTRL, leds: (empty), phys_code: Some(K3), raw_code: 12, repeat_count: 1, key_is_down: true, handled: Handled(false) }
13:57:01.011 INFO wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: Char('#'), modifiers: SHIFT | CTRL, leds: (empty), repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(K3), modifiers: SHIFT | CTRL, leds: (empty), phys_code: Some(K3), raw_code: 12, repeat_count: 1, key_is_down: true, handled: Handled(false) }) }
13:57:01.011 INFO wezterm_gui::termwindow::keyevent > send to pane DOWN key=Char('#') mods=SHIFT | CTRL
13:57:01.011 INFO wezterm_term::terminalstate::keyboard > key_down: sending "#", Char('#') SHIFT | CTRL
13:57:01.201 INFO wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: Char('§'), modifiers: SHIFT | CTRL, leds: (empty), repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(K3), modifiers: SHIFT | CTRL, leds: (empty), phys_code: Some(K3), raw_code: 12, repeat_count: 1, key_is_down: false, handled: Handled(false) }) }
13:57:01.201 INFO wezterm_gui::termwindow::keyevent > send to pane UP key=Char('§') mods=SHIFT | CTRL
13:57:01.419 INFO wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: LeftControl, modifiers: SHIFT | CTRL, leds: (empty), repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: SHIFT | CTRL, leds: (empty), phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: false, handled: Handled(false) }) }
13:57:01.419 INFO wezterm_gui::termwindow::keyevent > send to pane UP key=LeftControl mods=SHIFT | CTRL
13:57:01.424 INFO wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: LeftShift, modifiers: SHIFT, leds: (empty), repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(LeftShift), modifiers: SHIFT, leds: (empty), phys_code: Some(LeftShift), raw_code: 50, repeat_count: 1, key_is_down: false, handled: Handled(false) }) }
13:57:01.424 INFO wezterm_gui::termwindow::keyevent > send to pane UP key=LeftShift mods=SHIFT
It looks like the same problem as in my (old) issue #4259, where the down event is wrong (taking the char from QWERTY layout) but the up event is correct (taking the char from your layout).
To workaround this you can try to bind to the raw_code found in the logs, like this:
{ key = 'raw:12', mods = 'SHIFT|CTRL', action = act.ActivateTab(2) }
Q: You mention in the title when default keybindings are disabled, does it work with the default config?
Hey,
When I remove config.disable_default_key_bindings = true it works fine. With this line in my config, I have the issues.
Your workaround worked for me (with default key findings on or off).
Thank you.
I'm suspecting that default keybinds for numbers actually bind to the raw keys, that would explain why it works all the time by default.
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.