Appearance
For AI agents
Retrofitting an app with remap is a mechanical, one-pass task. This page is written to be pasted into an agent's context (or found by one).
The recipe
Wrap the app root once:
tsximport { RemapProvider } from "react-remap"; // in the root component: <RemapProvider appId="<the app's production hostname>">…</RemapProvider>Find every existing keyboard handler (
onKeyDownswitches,keydownlisteners, other hotkey libraries) and replace each action with:tsxuseHotkey("<area>.<verb>", "<current default combo>", handler, { description: "<human label>", group: "<section>", });Keep the app's current combos as defaults — users remap, you don't.
Do NOT build a shortcuts settings page. The ⌘, overlay is the settings page. If the app has a menu, add one item that calls
useRemap().openSettings().Update visible hints (tooltips, menu accelerators) to render live combos:
displayParts(useRemap().keysFor(id) ?? defaultCombo).
Constraints an agent must respect
Ids are stable API — pick
area.verbnames and never rename casually.modmeans ⌘/Ctrl per platform; prefer it overcmd/ctrlin defaults.Handlers that must work while typing in inputs need
enableOnFormTags: true.SSR (Next.js): the provider is client-side — mark the wrapping component
"use client". It toucheswindowonly inside effects.Actions that live outside React can subscribe instead of using the hook:
tswindow.addEventListener("remap:action", (e) => { const { id } = (e as CustomEvent).detail; if (id === "editor.save") save(); });(Register the shortcut itself via the provider's
shortcutsprop.)
Verification checklist
- Every shortcut appears in the ⌘, overlay with a human description.
- Remapping a combo in the overlay updates any visible hint immediately.
- Old handler paths are deleted — no double-firing.
- Shortcuts stay dead while typing in form fields (unless intentionally enabled).