Skip to content

Modified character keys bypass the kitty keyboard protocol: M-<letter> sends legacy ESC, C-M-<letter> drops meta #579

Closed

Description

@ashlineldridge

Summary

When the running program has enabled the kitty keyboard protocol, ghostel
still encodes modified character keys with legacy sequences: M-<letter>
goes out as ESC <letter> (which kitty-mode programs reject as ambiguous
instead of reading as alt), and C-M-<letter> is sent as the bare control
byte — the meta modifier is silently dropped. Modified functional keys
(backspace, return, arrows) encode correctly as CSI-u.

In practice this makes alt-key bindings dead in semi-char mode for any
kitty-negotiating TUI (pi, Claude Code, kkp-enabled apps): M-b/M-f/M-d
word motion, C-M-<letter> chords, etc.

Steps to reproduce

  1. M-x ghostel, then run: printf '\e[>1u'; cat -v (push the kitty
    disambiguate flag and capture input bytes).
  2. Press M-t → cat shows ^[t. Expected under kitty: ^[[116;3u.
  3. Press C-M-s → shows ^S (meta lost). Expected: ^[[115;7u.
  4. Press M-<backspace> → shows ^[[127;3u — correct, demonstrating the
    functional-key path already does the right thing.

Same results via ghostel-send-key ("t" "meta" / "s" "ctrl,meta").

Root cause

The native encoder produces no output for these keys, so
ghostel--send-encoded falls back to ghostel--raw-key-sequence
(lisp/ghostel.el:1578). That function's character-key branches are
kitty-unaware: the ctrl branch matches first and emits char & 0x1f
(dropping any meta bit), and the meta+printable branch always emits
ESC <char>. Its special-key branches, by contrast, emit CSI-u for
modified variants — hence backspace/return/arrows working.

Suggested fix

When the terminal has kitty flags active, emit CSI-u for modified
character keys too (mirroring the existing special-key branches), keeping
the current legacy sequences for non-kitty programs.

Environment

  • ghostel 0.47.0 (main, a2fe16d), prebuilt module
  • Emacs 31.0.90 (emacs-plus, GUI), macOS aarch64-apple-darwin25.5
  • Reproduced against latest main

Activity

  1. added 2 commits that reference this issue on Jul 29, 2026
    88f08f3
    fbadad2
  2. dakra commented on Jul 29, 2026

    @dakra
    Owner

    Should be fixed in the latest release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions