Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Ctrl+Shift+C (and Ctrl+C with a selection) send ^C instead of copying on Linux/Windows

未关闭 适合新手
#204 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
frontend

调研方向

按键处理逻辑位于 lib/input-handler.ts 中的 handleKeyDown,目前它只对 metaKey 加 KeyC 做了特殊处理,并调用已有的 onCopyCallback。运行 issue 中的复现片段,确认带有 ctrlKey 和 shiftKey 的 keydown 仍会以 "\u0003" 的形式传给 onData。完成标准是:Ctrl+Shift+C 调用复制回调,且不向 PTY 发送任何内容;Ctrl+C 只在存在选区时复制,否则仍发送 ^C。另外检查 Cmd+C 路径的行为保持不变。

由索引模型根据 Issue 内容生成。

描述

Summary

On Linux and Windows there is no keyboard way to copy the terminal selection: Ctrl+Shift+C (the terminal copy chord everywhere on those platforms) is passed to the key encoder and sent to the PTY as ^C (0x03), and plain Ctrl+C with text selected also sends ^C. Only Cmd+C (macOS, event.metaKey && event.code === 'KeyC') triggers the copy path. In a shell this means the user selects text, presses the copy shortcut, and interrupts their running program.

Seen on [email protected]; main (lib/input-handler.ts) still only special-cases metaKey + KeyC.

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.write('hello world');
  term.select(0, 0, 5);            // "hello"
  console.log(term.getSelection()); // "hello"
  term.focus();
  term.element.dispatchEvent(new KeyboardEvent('keydown', { key: 'C', code: 'KeyC', ctrlKey: true, shiftKey: true, bubbles: true, cancelable: true }));
</script>

Actual: onData receives "\u0003"; the clipboard is untouched. Expected: the selection is copied and nothing is sent to the PTY (Ctrl+Shift+C), and ideally Ctrl+C copies instead of interrupting when a selection exists (xterm.js users get this from attachCustomKeyEventHandler; Windows Terminal and GNOME Terminal behave this way).

Suggested fix

In handleKeyDown, treat (ctrlKey && shiftKey && code === 'KeyC') as copy using the existing onCopyCallback (always swallow it, never forward ^C), and ctrlKey && !shiftKey && code === 'KeyC' as copy when onCopyCallback() reports a selection.

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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

coder/ghostty-web 的其他 Issue

查看 coder/ghostty-web 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。