Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Alt+<printable key> sends the bare key with no ESC prefix (readline/emacs/tmux meta bindings lost)

オープン 初心者向け
#203 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
frontend

調査の方向性

lib/input-handler.ts から始めてください。ここでは isPrintableCharacter が Alt 修飾のキーを除外し、handleKeyDown がそれらをキーエンコーダーに渡しています。KeyEncoderOption.ALT_ESC_PREFIX が実際に設定されることがあるかを確認してください。完了の条件は、ディスパッチされた Alt+b が文字列 "\u001bb" を生成すること、Alt+ArrowLeft と Alt+Backspace が従来どおりエンコードされ続けること、そして #109 で言及されている macOS のパスを壊さずに Linux で変更が動作することです。

索引モデルが issue の本文から書いたものです。

説明

Summary

Alt+<printable key> sends the bare key with no ESC prefix. Terminal applications rely on the meta prefix (readline Alt-b/Alt-f/Alt-d, emacs M-x, tmux/vim meta mappings), so all of them silently lose their Alt bindings. This is the Linux/Windows case of what #109 describes for macOS: isPrintableCharacter() correctly refuses Alt-modified keys, but they then reach the Ghostty key encoder without KeyEncoderOption.ALT_ESC_PREFIX ever being set, so the encoder emits just the character.

Seen on [email protected] (Chromium 14x on Linux). The same code path is unchanged on main (lib/input-handler.ts: isPrintableCharacter returns false for Alt, nothing sets ALT_ESC_PREFIX). (Shift+Tab from #109 is fixed on main but not in the published 0.4.0 -- see #137.)

Minimal reproduction

<div id="t"></div>
<script type="module">
  import { init, Terminal } from 'ghostty-web';
  await init();
  const term = new Terminal();
  term.open(document.getElementById('t'));
  term.onData((d) => console.log(JSON.stringify(d)));
  term.focus();
  // Press Alt+B, or dispatch it:
  term.element.dispatchEvent(new KeyboardEvent('keydown', { key: 'b', code: 'KeyB', altKey: true, bubbles: true, cancelable: true }));
</script>

Actual: "b". Expected (xterm.js, every native terminal, Ghostty itself with macos-option-as-alt/Linux defaults): "\u001bb".

Alt+ArrowLeft ("\u001b[1;3D") and Alt+Backspace ("\u001b\u007f") are fine, so the encoder path itself works; only the printable-key case loses the prefix.

Suggested fix

Either set KeyEncoderOption.ALT_ESC_PREFIX on the encoder (it is already a defined option) and let Alt+printable go through it, or handle altKey && !ctrlKey && !metaKey && event.key.length === 1 in handleKeyDown by emitting '\x1b' + event.key (on macOS, derive the letter from event.code as proposed in #109, since event.key is the composed character there).

Found while evaluating ghostty-web as a PTY renderer for https://github.com/erisera-code/clawser; the host currently works around it with attachCustomKeyEventHandler.

主要言語
TypeScript
スター
2.9k
フォーク
182
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

coder/ghostty-web のほかの issue

coder/ghostty-web の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。