kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
23.98k stars 969 forks source link

Keyboard mapping `map cmd+< next_tab` does not work on Mac in 0.36.2 #7831

Closed stiang closed 3 weeks ago

stiang commented 3 weeks ago

Describe the bug After upgrading to 0.36.2 the keyboard mapping map cmd+< next_tab does not work anymore (nothing happens).

Using the build-in keyboard mapping for the same operation (cmd+;) works as expected.

I also tried using map cmd+0x3c next_tab, which is what kitty --debug-keyboard tells me is the hex code for that key, but that didn’t work either.

To isolate the problem I have removed everything from my config except this keyboard mapping, and the mapping still doesn’t work.

As the debug output below shows, the mapping isn’t defined at all.

To Reproduce Steps to reproduce the behavior:

  1. Add the keyboard mapping map cmd+< next_tab on a Mac
  2. Reload the configuration
  3. Open several tabs
  4. Observe that hitting cmd+< does nothing

Environment details Note that I’m using a Norwegian keyboard, where the < key is located immediately to the right of the left Shift key. But I guess this is not related to international keyboards, seeing as how the keyboard mapping isn’t defined at all.

Debug output:

kitty 0.36.2 (15ac33a058) created by Kovid Goyal
Darwin Stians-Mac-mini.local 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:21 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8103 arm64
ProductName:        macOS ProductVersion:       14.6.1 BuildVersion:        23G93
OpenGL: '4.1 Metal - 88.1' Detected version: 4.1
Frozen: True
Fonts:
  medium: Menlo-Regular: /System/Library/Fonts/Menlo.ttc
          Features: ()
    bold: Menlo-Bold: /System/Library/Fonts/Menlo.ttc
          Features: ()
  italic: Menlo-Italic: /System/Library/Fonts/Menlo.ttc
          Features: ()
      bi: Menlo-BoldItalic: /System/Library/Fonts/Menlo.ttc
          Features: ()
Paths:
  kitty: /Applications/kitty.app/Contents/MacOS/kitty
  base dir: /Applications/kitty.app/Contents/Resources/kitty
  extensions dir: /Applications/kitty.app/Contents/Resources/Python/lib/kitty-extensions
  system shell: /bin/zsh
Loaded config files:
  /Users/stian/.config/kitty/kitty.conf

Config options different from defaults:
Removed shortcuts:
    cmd+, →  edit_config_file
    cmd+enter →  new_window
    cmd+h →  hide_macos_app
    cmd+k →  clear_terminal to_cursor active
    cmd+m →  minimize_macos_window
    cmd+n →  new_os_window
    cmd+q →  quit
    cmd+t →  new_tab
    cmd+w →  close_tab
    ctrl+cmd+, →  load_config_file
    ctrl+cmd+f →  toggle_fullscreen
    opt+cmd+h →  hide_macos_other_apps
    opt+cmd+r →  clear_terminal reset active
    opt+cmd+s →  toggle_macos_secure_keyboard_entry
    shift+cmd+/ →  open_url https://sw.kovidgoyal.net/kitty/
    shift+cmd+[ →  previous_tab
    shift+cmd+d →  close_window
    shift+cmd+w →  close_os_window

Important environment variables seen by the kitty process:
    PATH                                /Applications/kitty.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin
    LANG                                en_US.UTF-8
    SHELL                               /bin/zsh
    USER                                stian
kovidgoyal commented 3 weeks ago

Works for me with:

kitty --config=NONE -o 'map cmd+< next_tab'

It doesnt show up in the debug output becomes it becomes a "global shortcut" on macOS. macOS has a crazy system for dealing with keyboard shortcuts. You can see it by accessing the Window menu in the global menubar it will be listed next to the "Show Next tab" menu entry. Most likely this is a keyboard issue. Try pressing shift with it. Because this shortcut is "global" it's handled by macOS not kitty, so all the usual kitty facilities wont work like debugging mapping by key id etc.

stiang commented 3 weeks ago

Looks like you are right. I thought cmd+; was a built-in shortcut for next_tab, but it’s not - it’s what cmd+< gets "translated" to. And it fits - the '<' key is to the right of 'M' on a US keyboard, but on a Norwegian keyboard, that’s where ';' is.

I tried tricking it into using the key on a US keyboard that’s to the right of the left Shift, which looks like it is the \ key, but it didn’t work.

Guess I’ll just have to figure out a different shortcut for next_tab, which is a bummer, because it’s probably my most-used shortcut.

This did work with my previous version of kitty, though, which I think was 0.33.x.

Thanks for looking into it.

kovidgoyal commented 3 weeks ago

Yeah that's because the Next tab item was added to the global menubar to match other terminals on macOS.