
Security News
US Government Forces Anthropic to Pull Claude Fable Days After Launch
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.
@opentui/keymap
Advanced tools
A host-agnostic keymap engine for terminal and DOM apps. Same core, multiple adapters.
It models keybindings as priority-ordered, focus-scoped layers attached to targets (terminal renderables or DOM elements). The core is intentionally bare; everything beyond raw key dispatch is opt-in via addons, parsers, expanders, resolvers, and field compilers.
KeymapHost interface with host metadata, focus, parent traversal, target destruction, key press/release, optional raw input, and synthetic command events.focus / focus-within layers that follow the active target's parent chain.fallthrough, and preventDefault control.pendingSequence events, active continuation queries, and automatic invalidation on focus changes.g vs gg) with runExact, continueSequence, clear, and deferred AbortSignal + sleep decisions. Ships a Neovim-style timeout resolver.attrs; all field kinds can gate activation via require(...) and activeWhen(matcher).consume({ preventDefault, stopPropagation }), post-dispatch handled/no-match outcomes, and raw input stop() handling.registered / reachable / active), binding queries, runCommand, and focus-aware dispatchCommand.super, hyper, and literal + bindings.registerModBindings, resolving mod+... from host metadata while preserving display strings.@opentui/keymap/addons ships ready-made building blocks:
registerDefaultKeys — ctrl+shift+s style parser and event matching.registerLeader, registerTimedLeader — leader tokens with optional timeout.registerEmacsBindings — ctrl+x ctrl+s chords.registerExCommands — :write-style commands with aliases and nargs.registerCommaBindings, registerModBindings, registerAliasesField, registerBindingOverrides.registerEnabledFields, registerMetadataFields (desc, group, title, category).registerNeovimDisambiguation, registerEscapeClearsPendingSequence, registerBackspacePopsPendingSequence.registerDeadBindingWarnings, registerUnresolvedCommandWarnings.@opentui/keymap/addons/opentui adds OpenTUI-specific pieces: layout-independent matching via event.baseCode, and pre-wired textarea / edit-buffer commands. Direct event matches win before fallback matches, even across layers.
@opentui/keymap — core API@opentui/keymap/addons — universal addons@opentui/keymap/addons/opentui — universal + OpenTUI addons@opentui/keymap/extras/graph — graph snapshot helpers for debug and graph UIs@opentui/keymap/testing — host-agnostic fake keymap host and diagnostics for addon tests@opentui/keymap/html — HTML adapter@opentui/keymap/opentui — OpenTUI adapter@opentui/keymap/react — KeymapProvider, useKeymap, useBindings, useActiveKeys, usePendingSequence, reactiveMatcherFromStore@opentui/keymap/solid — KeymapProvider, useKeymap, useKeymapSelector, useBindings, reactiveMatcherFromSignal@opentui/keymap/extras — helpers for cheat-sheet UIs (createBindingLookup, commandBindings, formatCommandBindings)import { registerDefaultKeys } from "@opentui/keymap/addons"
import { createOpenTuiKeymap } from "@opentui/keymap/opentui"
import { KeymapProvider } from "@opentui/keymap/react"
const keymap = createOpenTuiKeymap(renderer)
registerDefaultKeys(keymap)
createRoot(renderer).render(
<KeymapProvider keymap={keymap}>
<App />
</KeymapProvider>,
)
Create a keymap, install the addons you want, then pass the configured instance to your app. The React and Solid entrypoints consume a pre-created OpenTUI keymap through context.
Keymap is the core runtime. Pass feature factories to its constructor when you need graph snapshots or layer analyzers.
Adapters implement a small KeymapHost interface (metadata, rootTarget, getFocusedTarget, getParentTarget, onKeyPress, onKeyRelease, onFocusChange, onTargetDestroy, ...). The HTML adapter normalizes DOM key names (Escape → escape, ArrowUp → up, Meta → super, Alt → meta) and tracks targets via MutationObserver. The OpenTUI adapter hooks CliRenderer keypress, keyrelease, focus, destroy, target destroy, and raw input events.
Use keymap.formatKey when displaying raw binding strings. It runs them through the keymap's parsers and tokens before stringifying.
keymap.formatKey("<leader>s", { separator: " " }) // "space s"
keymap.formatKey("<leader>s", { preferDisplay: true }) // "<leader>s"
Runtime/data re-entry is supported during dispatch: command handlers, intercepts, and pending-sequence listeners may read or write runtime data and pending-sequence state.
Structural re-entry is not supported. Do not register or unregister layers, tokens, parsers, or resolvers while a dispatch is in flight.
bun install @opentui/keymap
bun run build
bun run test
bun src/keymap-benchmark.ts
The HTML demo lives in the docs app at /demos/keymap-html/ under packages/web.
FAQs
Standalone keymap package for OpenTUI
The npm package @opentui/keymap receives a total of 19,422 weekly downloads. As such, @opentui/keymap popularity was classified as popular.
We found that @opentui/keymap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.