Skip to main content

Duck Vim

Typed keyboard command engine for React. Hotkey parser, sequence matcher, chord bindings, key recorder, and platform-aware `Mod`.

Keyboard engine

A typed keyboard command engine

Parse hotkey strings, match live events, run chords and sequences, and record user input for a settings page. React hooks included.

useKeyBind

Bind a single combo. `ctrl+k`, `meta+shift+p`, `mod+s`. Platform-aware, with `preventDefault`.

useKeySequence

Multi-step sequences like `g` then `d`. Configurable timeout between steps and chord-mode support.

useKeyCommands

Register a whole command palette at once. Bind each command to a shortcut and render the list.

useKeyRecorder

Record user input for settings UIs. Users pick their own shortcuts and you persist the result.

Platform-aware Mod

`Mod` resolves to `Cmd` on macOS and `Ctrl` everywhere else. Write one binding that feels native on both.

Framework-agnostic core

Parser, matcher, sequence engine, and recorder live in plain TypeScript. The React hooks are a thin binding layer.

Install

Wrap your app in `KeyProvider`, then bind.

# Install
bun add @gentleduck/vim

# Bind your first shortcut
import { KeyProvider, useKeyBind } from '@gentleduck/vim/react'

Free & open source

gentleduck is MIT licensed and will always be free and open source. Every package ships with full source access — fork it, modify it, own it.

Become a Sponsor