Kitty Terminal: Send_key Inconsistency

by Admin 39 views
Kitty Terminal `send_key` Inconsistent Behavior

Hey guys! πŸ‘‹ I've been wrestling with a weird issue in kitty terminal, and I wanted to see if anyone else has bumped into it. Specifically, it has to do with the send_key action, which seems to behave differently between kitty versions 0.43.1 and 0.44.0. Let's dive in! πŸ‘‡

The Bug: send_key Fails in Version 0.44.0

So, here's the deal: I've got a config setting in my kitty.conf file that looks like this. It's designed to clear the terminal screen and then trigger a shortcut in my shell (fish, in this case). 🐠

map ctrl+l          combine : clear_terminal reset active : send_key alt+r

In kitty version 0.43.1, everything works like a charm. When I hit Ctrl+L, the screen clears, and then the alt+r shortcut is sent to the fish shell. This triggers the shell to redraw the prompt as expected. πŸ‘

However, in version 0.44.0, things go sideways. The screen still clears, but instead of executing the alt+r shortcut, I get the characters ^[r printed on the screen, and nothing else happens. It's like kitty isn't properly interpreting the send_key command anymore. πŸ˜’

This inconsistency is a real bummer because it breaks some of my workflow. Any ideas what might be causing this, or if there's a workaround? πŸ€”

To Reproduce the Bug

If you want to see this firsthand, here’s how you can reproduce the issue:

  1. Install kitty 0.44.0: Make sure you have the latest version installed.
  2. Configure kitty.conf: Add the mapping described above to your kitty.conf file.
  3. Open kitty: Launch your kitty terminal.
  4. Trigger the command: Press Ctrl+L in the terminal.
  5. Observe the behavior: You should see the ^[r characters instead of the shortcut being executed. 🧐

Additional Information to Consider

I've included some environment details below that might be helpful for diagnosing the problem. If you spot anything that stands out, let me know! πŸ’‘

Environment details

I hope this helps us get to the bottom of this issue, and thanks for taking the time to read through it, folks! πŸ™

Environment Details

Here's a breakdown of my system setup. Perhaps there's something here that could provide a clue:

kitty 0.44.0 created by Kovid Goyal
Linux archlinux 6.12.57-1-lts #1 SMP PREEMPT_DYNAMIC Sun, 02 Nov 2025 15:08:33 +0000 x86_64
Arch Linux 6.12.57-1-lts (/dev/tty)
Running under: Wayland (kwin 6.5.2) missing: color-manager
OpenGL: '4.5 (Core Profile) Mesa 25.2.6-arch1.1' Detected version: 4.5
Frozen: False
Fonts:
  medium: Sarasa-Fixed-SC-Nerd-Font-Regular: /usr/share/fonts/sarasa-gothic-nerd-fonts/sarasa-regular-nerd-font.ttc:4
          Features: ()
    bold: Sarasa-Fixed-SC-Nerd-Font-SemiBold: /usr/share/fonts/sarasa-gothic-nerd-fonts/sarasa-semibold-nerd-font.ttc:4
          Features: ()
  italic: Sarasa-Fixed-SC-Nerd-Font-Italic: /usr/share/fonts/sarasa-gothic-nerd-fonts/sarasa-italic-nerd-font.ttc:4
          Features: ()
      bi: Sarasa-Fixed-SC-Nerd-Font-SemiBold-Italic: /usr/share/fonts/sarasa-gothic-nerd-fonts/sarasa-semibolditalic-nerd-font.ttc:4
          Features: ()
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib/kitty
  extensions dir: /usr/lib/kitty/kitty
  system shell: /usr/bin/fish
System color scheme: light. Applied color theme type: none
Loaded config files:
  /home/cc/.config/kitty/kitty.conf

Config options different from defaults:
allow_remote_control    yes
clipboard_control       ('write-clipboard', 'write-primary', 'read-clipboard', 'read-primary')
cursor_text_color       None
enabled_layouts         ['grid']
font_family             family="Sarasa Fixed SC Nerd Font"
font_size               12.0
listen_on               unix:/tmp/kitty
shell_integration       frozenset({'no-cursor'})
tab_bar_min_tabs        1
tab_bar_style           custom
window_padding_width    FloatEdges(left=6.0, top=2.0, right=6.0, bottom=2.0)
Added shortcuts:
	alt+0 β†’  next_window
	alt+9 β†’  previous_window
	alt+[ β†’  previous_tab
	alt+] β†’  next_tab
	alt+f > u β†’  kitty_scrollback_nvim --config ksb_builtin_last_cmd_output, kitty_scrollback_nvim, hints --type hash --program "launch --type=overlay select-string-operation.sh", hints --type word --program "launch --type=overlay select-string-operation.sh", hints --type line --program "launch --type=overlay select-string-operation.sh", hints --type path --program "launch --type=overlay select-path-operation.sh", hints
	alt+i β†’  [--when-focus-on=var:in_editor]no-op, scroll_line_up
	alt+j β†’  [--when-focus-on=var:in_editor]no-op, scroll_to_prompt -1
	alt+k β†’  [--when-focus-on=var:in_editor]no-op, scroll_line_down
	alt+l β†’  [--when-focus-on=var:in_editor]no-op, scroll_to_prompt 1
	alt+o β†’  [--when-focus-on=var:in_editor]no-op, scroll_end
	alt+page_down β†’  [--when-focus-on=var:in_editor]no-op, scroll_page_down
	alt+page_up β†’  [--when-focus-on=var:in_editor]no-op, scroll_page_up
	alt+super+, β†’  debug_config
	alt+u β†’  [--when-focus-on=var:in_editor]no-op, scroll_home
	ctrl+0 β†’  goto_tab 10
	ctrl+1 β†’  goto_tab 1
	ctrl+2 β†’  goto_tab 2
	ctrl+3 β†’  goto_tab 3
	ctrl+4 β†’  goto_tab 4
	ctrl+5 β†’  goto_tab 5
	ctrl+6 β†’  goto_tab 6
	ctrl+7 β†’  goto_tab 7
	ctrl+8 β†’  goto_tab 8
	ctrl+9 β†’  goto_tab 9
	ctrl+c β†’  [--when-focus-on=var:in_editor]no-op, copy_and_clear_or_interrupt
	ctrl+escape β†’  kitty_shell window
	ctrl+f5 β†’  load_config_file
	ctrl+l β†’  [--when-focus-on=var:in_editor]no-op, combine : clear_terminal reset active : send_key alt+r
	ctrl+p β†’  launch --cwd=current
	ctrl+shift+f6 β†’  debug_config
	ctrl+shift+l β†’  [--when-focus-on=var:in_editor]no-op, clear_terminal reset active
	ctrl+t β†’  new_tab !neighbor
	ctrl+v β†’  [--when-focus-on=var:in_editor]no-op, paste_from_clipboard
	ctrl+w β†’  [--when-focus-on=var:in_editor]no-op, close_window
	shift+alt+0 β†’  move_window_forward
	shift+alt+9 β†’  move_window_backward
	shift+alt+[ β†’  move_tab_backward
	shift+alt+] β†’  move_tab_forward
	shift+super+l β†’  [--when-focus-on=var:in_editor]no-op, clear_terminal reset active
	super+0 β†’  goto_tab 10
	super+1 β†’  goto_tab 1
	super+2 β†’  goto_tab 2
	super+3 β†’  goto_tab 3
	super+4 β†’  goto_tab 4
	super+5 β†’  goto_tab 5
	super+6 β†’  goto_tab 6
	super+7 β†’  goto_tab 7
	super+8 β†’  goto_tab 8
	super+9 β†’  goto_tab 9
	super+c β†’  [--when-focus-on=var:in_editor]no-op, copy_and_clear_or_interrupt
	super+f5 β†’  load_config_file
	super+l β†’  [--when-focus-on=var:in_editor]no-op, combine : clear_terminal reset active : send_key alt+r
	super+p β†’  launch --cwd=current
	super+t β†’  new_tab !neighbor
	super+v β†’  [--when-focus-on=var:in_editor]no-op, paste_from_clipboard
	super+w β†’  [--when-focus-on=var:in_editor]no-op, close_window
Removed shortcuts:
	ctrl+shift+tab β†’  previous_tab
	ctrl+tab β†’  next_tab
	kitty_mod++ β†’  change_font_size all +2.0
	kitty_mod+, β†’  move_tab_backward
	kitty_mod+- β†’  change_font_size all -2.0
	kitty_mod+. β†’  move_tab_forward
	kitty_mod+0 β†’  tenth_window
	kitty_mod+1 β†’  first_window
	kitty_mod+2 β†’  second_window
	kitty_mod+3 β†’  third_window
	kitty_mod+4 β†’  fourth_window
	kitty_mod+5 β†’  fifth_window
	kitty_mod+6 β†’  sixth_window
	kitty_mod+7 β†’  seventh_window
	kitty_mod+8 β†’  eighth_window
	kitty_mod+9 β†’  ninth_window
	kitty_mod+= β†’  change_font_size all +2.0
	kitty_mod+[ β†’  previous_window
	kitty_mod+] β†’  next_window
	kitty_mod+` β†’  move_window_to_top
	kitty_mod+a > m β†’  set_background_opacity default, set_background_opacity 1, set_background_opacity -0.1, set_background_opacity +0.1
	kitty_mod+alt+t β†’  set_tab_title
	kitty_mod+b β†’  move_window_backward
	kitty_mod+backspace β†’  change_font_size all 0
	kitty_mod+c β†’  copy_to_clipboard
	kitty_mod+delete β†’  clear_terminal reset active
	kitty_mod+down β†’  scroll_line_down
	kitty_mod+e β†’  open_url_with_hints
	kitty_mod+end β†’  scroll_end
	kitty_mod+enter β†’  new_window
	kitty_mod+escape β†’  kitty_shell window
	kitty_mod+f β†’  move_window_forward
	kitty_mod+f1 β†’  show_kitty_doc overview
	kitty_mod+f10 β†’  toggle_maximized
	kitty_mod+f11 β†’  toggle_fullscreen
	kitty_mod+f2 β†’  edit_config_file
	kitty_mod+f5 β†’  load_config_file
	kitty_mod+f6 β†’  debug_config
	kitty_mod+f7 β†’  focus_visible_window
	kitty_mod+f8 β†’  swap_with_window
	kitty_mod+g β†’  show_last_command_output
	kitty_mod+h β†’  show_scrollback
	kitty_mod+home β†’  scroll_home
	kitty_mod+j β†’  scroll_line_down
	kitty_mod+k β†’  scroll_line_up
	kitty_mod+kp_add β†’  change_font_size all +2.0
	kitty_mod+kp_subtract β†’  change_font_size all -2.0
	kitty_mod+l β†’  next_layout
	kitty_mod+left β†’  previous_tab
	kitty_mod+n β†’  new_os_window
	kitty_mod+o β†’  pass_selection_to_program
	kitty_mod+p > f β†’  kitten hints --type hyperlink, kitten hints --type linenum, kitten hints --type hash --program -, kitten hints --type word --program -, kitten hints --type line --program -, kitten hints --type path, kitten hints --type path --program -
	kitty_mod+page_down β†’  scroll_page_down
	kitty_mod+page_up β†’  scroll_page_up
	kitty_mod+q β†’  close_tab
	kitty_mod+r β†’  start_resizing_window
	kitty_mod+right β†’  next_tab
	kitty_mod+s β†’  paste_from_selection
	kitty_mod+t β†’  new_tab
	kitty_mod+u β†’  kitten unicode_input
	kitty_mod+up β†’  scroll_line_up
	kitty_mod+v β†’  paste_from_clipboard
	kitty_mod+w β†’  close_window
	kitty_mod+x β†’  scroll_to_prompt 1
	kitty_mod+z β†’  scroll_to_prompt -1
	shift+insert β†’  paste_from_selection
Colors:
	active_tab_background   #f8f8f2   
	active_tab_foreground   #282a36   
	background              #282a36   
	color0                  #21222c   
	color1                  #ff5555   
	color10                 #69ff94   
	color11                 #ffffa5   
	color12                 #d6acff   
	color13                 #ff92df   
	color14                 #a4ffff   
	color2                  #50fa7b   
	color3                  #f1fa8c   
	color4                  #bd93f9   
	color5                  #ff79c6   
	color6                  #8be9fd   
	color7                  #f8f8f2   
	color8                  #6272a4   
	color9                  #ff6e6e   
	cursor                  #f8f8f2   
	foreground              #f8f8f2   
	inactive_tab_background #6272a4   
	inactive_tab_foreground #282a36   
	mark1_background        #ff5555   
	mark1_foreground        #282a36   
	selection_background    #44475a   
	selection_foreground    #ffffff   
	url_color               #8be9fd   

Important environment variables seen by the kitty process:
	PATH                                /run/user/1000/fnm_multishells/896_1762791177572/bin:/home/cc/.local/share/cargo/bin:/home/cc/.local/share/go/bin:/home/cc/.local/share/pnpm:/home/cc/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin
	LANG                                zh_CN.UTF-8
	EDITOR                              /usr/bin/nvim
	SHELL                               /usr/bin/fish
	DISPLAY                             :0
	WAYLAND_DISPLAY                     wayland-0
	USER                                cc
	XDG_RUNTIME_DIR                     /run/user/1000
	XDG_CACHE_HOME                      /home/cc/.cache
	XDG_CONFIG_DIRS                     /home/cc/.config/kdedefaults:/etc/xdg
	XDG_CONFIG_HOME                     /home/cc/.config
	XDG_CURRENT_DESKTOP                 KDE
	XDG_DATA_HOME                       /home/cc/.local/share
	XDG_MENU_PREFIX                     plasma-
	XDG_SEAT                            seat0
	XDG_SEAT_PATH                       /org/freedesktop/DisplayManager/Seat0
	XDG_SESSION_CLASS                   user
	XDG_SESSION_DESKTOP                 KDE
	XDG_SESSION_ID                      2
	XDG_SESSION_PATH                    /org/freedesktop/DisplayManager/Session1
	XDG_SESSION_TYPE                    wayland
	XDG_STATE_HOME                      /home/cc/.local/state
	XDG_VTNR                            2

I've included my system information, including details about my Linux distribution, display server (Wayland), and the configuration of my kitty terminal. I'm hoping this information helps shed some light on the issue. If you need any more details, just let me know! 🀠

Potential Causes and Troubleshooting Steps

Alright, let's brainstorm some potential reasons behind this kitty send_key behavior and some ways we might try to fix it. πŸ€”

1. Version-Specific Bugs: It's possible that this is a genuine bug introduced in kitty 0.44.0. Sometimes new versions come with unexpected glitches. If this is the case, the best course of action is to report the bug to the kitty developers (like Kovid Goyal, who created kitty), providing them with as much detail as possible (which we've already started!). πŸ›

2. Shell Interaction: The way kitty interacts with your shell (fish, in this case) might have changed between versions. The send_key command could be sending the key sequence in a way that fish, or other shells, is not correctly interpreting in the newer version.

3. Key Code Differences: It's remotely possible that the key codes being sent by the send_key action differ slightly between the two versions of kitty. The newer version may be sending a key code that isn't compatible with your shell. This is a stretch, but could cause a discrepancy.

4. Configuration Conflicts: Though less likely, there could be a subtle conflict in your kitty.conf file or other configuration files that affects the send_key command in 0.44.0. Maybe some other setting is interfering with this command.

Troubleshooting Steps:

To troubleshoot, here's what we can try:

  • Test with a Different Shell: See if the problem occurs with other shells, such as bash or zsh. If it works with other shells, that might indicate an issue with how kitty is interacting with fish.

  • Simplify the Command: Create a very basic send_key command to test. For example, try mapping Ctrl+L to send_key a. If this doesn't work, it indicates the problem may be broader than just alt+r.

  • Check Key Codes: Try to find out what key codes kitty is actually sending. You might use a keylogger tool within the terminal or check the kitty documentation to get more precise details.

  • Review Kitty's Changelog: Check the kitty changelog between 0.43.1 and 0.44.0 to see if there are any changes related to key handling or the send_key action. The changelog might give you valuable information.

  • Experiment with keymaps: It is possible the keymap of your system interferes with the send_key action. Try to use a different keymap to see if this solves the problem.

  • Inspect Kitty Logs: Enable more detailed logging in kitty (if possible) to see what's happening behind the scenes when you trigger Ctrl+L. This could provide some clues about how the send_key command is being processed.

Conclusion

This is a perplexing issue, and hopefully, we can pinpoint the root cause! If anyone has insights or suggestions, please share. And if you run into this problem too, let me know; it's always good to know we're not alone! πŸ‘

Thanks for reading, and happy terminal-ing, everyone! πŸŽ‰