GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(app): support key chords in shortcuts by Brendonovich · Pull Request #64395 · anomalyco/opencode

Conversation

@Brendonovich

@Brendonovich Brendonovich commented Nov 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Summary

Shortcuts can be key chords: a sequence of key presses separated by spaces, such as mod+k mod+c or g i. This is the second of three stacked PRs, based on the @opentui/keymap engine PR.

  • Keymap. Each binding parses into strokes. A chord whose first key types a character only starts outside text fields, so typing is never taken. A chord that starts with a modifier works anywhere. Escape cancels a pending chord and Backspace removes its last key.
  • Next-key panel. While a chord is pending, a panel near the bottom of the window lists the keys that continue it and the command each runs.
  • Labels. Chords show one keycap per stroke, for example ⌥G ⌥S, in Settings, the palette and tooltips. parseKeybind and matchKeybind still only match single-stroke combos.
  • Recording in Settings > Shortcuts. A key saves as soon as it is pressed, as before. The row just saved then shows +. Clicking it records one more key onto the shortcut, up to 4. Backspace while adding drops that key; with nothing before it, Backspace still unbinds the shortcut.
  • Conflicts now include prefixes. A chord is rejected when it starts, or is started by, another shortcut. For example ⌘K ⌘J is rejected because ⌘K opens the palette.

Before / After

Before After
Before: Open settings recorded as ⌥G, with no way to add a key After: Open settings recorded as ⌥G, with a + button

After clicking + and pressing ⌥S, and the next-key panel after pressing ⌥G in the prompt:

Chord saved Next-key panel
After: Open settings bound to ⌥G ⌥S After: next-key panel listing ⌥S Open settings

Captured at 1280×800 with the e2e mock server, on Settings > Shortcuts, with no stored settings.

Feature flag

None. No default shortcut is a chord, so nothing changes until a user records one.

Stack

  1. The @opentui/keymap engine.
  2. This PR: key chords.
  3. Leader key, based on this branch.

Validation

  • bun typecheck and lint pass in packages/app.
  • bun run test:unit (2739) and bun run test:browser (361) pass.
  • New tests:
    • keymap.test.ts: chords from text fields and elsewhere, and Escape and Backspace on a pending chord.
    • The recorder machine: saving at once, +, Backspace, and clashes.
    • The Settings controller: prefix conflicts and extending a shortcut.
    • Chord labels.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Brendonovich added 2 commits November 17, 2026 16:00
@Brendonovich
feat(app): dispatch command shortcuts through @opentui/keymap
acca4c3
@Brendonovich
feat(app): support key chords in shortcuts
c1378f0
@Brendonovich Brendonovich mentioned this pull request Nov 17, 2026
feat(app): run shortcuts through @opentui/keymap with chords and a leader key #64393
Closed
Brendonovich added 2 commits November 17, 2026 16:32
@Brendonovich
refactor(app): leave composer attach and stop keys to the command keymap
5c3ae7d
@Brendonovich
Merge branch 'keymap-engine' into keymap-chords
f2a6390
Base automatically changed from keymap-engine to dev November 18, 2026 03:12
opencodejr[bot]
opencodejr Bot reviewed Nov 18, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chord engine works in the happy-dom tests, but I couldn't see Settings > Shortcuts or the next-key panel in a real browser. I relied on your screenshots for those.

What I ran in packages/app:

  • unit tests for src/shell/commands and src/settings/keybinds: 84 pass
  • test:browser: 358 pass
  • tsc -b: clean
  • two small throwaway tests against createAppKeymap / registerCommandLayers, which show the two problems below

Public API: unchanged. The new @opentui/keymap dependency and the prompt.stop command stay inside the app. commandKeymap and resolveKeybindOption are no longer exported from command.tsx, but nothing outside the app uses them.

Two problems worth fixing, details inline:

  1. A pending chord is dropped whenever the command list changes, because every layer is re-registered.
  2. Chords on editable commands, which now includes the palette, still take typing in text fields.

Note that the base is dev, so this diff also contains the keymap engine commit.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/app/src/shell/commands/command.tsx
),
)

createEffect(() => {

@opencodejr opencodejr Bot Nov 18, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This effect throws away every keymap layer and registers new ones whenever options() recomputes. The engine then forgets any pending chord, because it only keeps captures whose layer is still registered. I checked it: press ctrl+k for a ctrl+k ctrl+c binding, re-register, press ctrl+c, and the pending sequence is gone and nothing runs. options() recomputes on ordinary state changes, e.g. prompt.stop's disabled flips when a session starts or stops. So a chord can be cancelled halfway through for no visible reason, and every recompute rebuilds all layers. Could registration only happen when the bindings actually change? Or could disabled and the other reactive state be handled through the engine's conditions or a check at run time, instead of re-registering everything?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/app/src/shell/commands/keymap.ts
.map((combo) => {
const key = keymapKey(combo)

return { key, cmd: option.id, outsideText: !option.editable && typesCharacter(keymap, key) }

@opencodejr opencodejr Bot Nov 18, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a command is editable, the outsideText guard is skipped, and command.tsx now makes the palette editable unconditionally. So if the palette (or any of the other editable commands) is recorded as a plain-letter chord like g p, pressing g in the composer is swallowed and starts a pending chord. I checked it: default prevented, sequence pending. The description says a chord whose first key types a character only starts outside text fields. editable makes sense for modified single strokes, but should a sequence whose first key types a character stay out of text fields even for editable commands?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Brendonovich
Merge branch 'dev' into keymap-chords
874146b
@Brendonovich
Brendonovich merged commit 2720b4b into dev Nov 23, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Brendonovich
Brendonovich deleted the keymap-chords branch November 23, 2026 05:23
This was referenced Nov 23, 2026
feat(keymap): a shortcut can be a chord of several strokes, as official's (#64395) anomalyco/opencode-rune#833
Merged
feat(keymap): a chord shows on every label of its command, as official's (#64395) anomalyco/opencode-rune#835
Merged
A key chord only runs with its modifier held from the first key to the last #65734
Open
fix(app): keep a key chord going when its modifier is released between keys #65735
Closed
@neriousy neriousy mentioned this pull request Nov 23, 2026
[FEATURE]: Desktop/Web: support customizable multi-step keyboard shortcuts #63522
Closed
1 task done
@BrewTestBot BrewTestBot mentioned this pull request Nov 23, 2026
opencode 2.4.0 Homebrew/homebrew-core#327368
Merged
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
opencode 2.4.0 amrkmn/homebrew-tap#1251
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
feat: opencode release v2.4.0 sprisa/opencode-server#95
Merged
@scottames-github-bot scottames-github-bot Bot mentioned this pull request Nov 27, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#1181
Merged
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Brendonovich
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.