Skip to content

Terminal hotkeys

You will add standalone terminal commands and a custom clear shortcut. Start with the synchronous main entry.

hotkeys.ts
import { Terminal, attachTerminalHotkeys } from 'ghostty-webgpu'
export async function mountHotkeys(host: HTMLElement) {
const terminal = await Terminal.create()
const connection = attachTerminalHotkeys(terminal, {
mode: 'standalone',
bindings: [{ keys: 'Ctrl+Q', command: 'terminal.clear', context: 'Terminal', source: 'user' }],
})
await terminal.open(host)
return () => {
connection.dispose()
terminal.dispose()
}
}

The connection attaches when the terminal opens. Its disposer removes the registration. Terminal disposal also aborts the connection and pending clipboard work. One finite original-input connection owns a terminal at a time.

ActionmacOSLinux and Windows
CopyCmd+CCtrl+Shift+C
PasteCmd+VCtrl+Shift+V
Select allCmd+ACtrl+Shift+A
ClearCmd+KCtrl+Shift+K
Increase font sizeCmd+=Ctrl+=
Decrease font sizeCmd+-Ctrl+-
Reset font sizeCmd+0Ctrl+0

Clear erases the display and scrollback while keeping protocol modes. Copy declines an empty selection. Paste uses the owning window’s Clipboard API.

A host with @fregat/hotkeys can pass mode: 'hosted', its dispatcher, the parent focus node and platform. The host owns the bindings and matcher. terminalDefaultPack and terminalShellKeysPack export binding data. The hotkeys integration note covers the focus adapter.

Use a secure context and a user gesture. Provide clipboard: { readText, writeText } and onError when your host has a different clipboard policy.

Worker attachment reports a capability error

Section titled “Worker attachment reports a capability error”

This adapter needs immediate native input-mode authority. Use the main entry for finite synchronous hotkeys ownership.

Next, read scrollback.