npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vielzeug/keymap

v1.1.1

Published

Headless keyboard shortcut manager with chord sequences, context guards, and disposable bindings

Readme

@vielzeug/keymap

Headless keyboard shortcut manager with chord sequences, per-binding context guards, dynamic bindings, trigger control, conflict detection, and disposable lifecycle.

Features

  • Chord sequences"g g", "ctrl+k ctrl+s" with a configurable timeout
  • Special key aliasesspace, esc, up, down, left, right, del
  • Modifier aliasescmd/command/winmeta; opt/optionalt; controlctrl; modmeta on Mac, ctrl elsewhere
  • modKey option — explicit platform override for cross-platform tests and SSR
  • Per-binding BindingOptions{ handler, when?, trigger?, priority? } object syntax
  • trigger option'keydown' (default) or 'keyup' per binding
  • Dynamic bindingsmap.bind() / map.unbind() at any time — the most recent bind() for a shortcut always wins
  • findShortcutConflicts() — detect prefix/duplicate conflicts before binding a user-customized shortcut
  • formatShortcut() — platform-aware display formatter (⇧⌘P on Mac, Ctrl+Shift+P elsewhere)
  • createKeymapLayer() — scoped keymap stack with activate() / deactivate()
  • Headless — accepts any EventTarget; works without a DOM (SSR, Node tests)
  • Disposabledispose() + [Symbol.dispose] for using declarations

Install

pnpm add @vielzeug/keymap

Quick start

import { createKeymap, formatShortcut } from '@vielzeug/keymap';

const map = createKeymap({
  'mod+k mod+s': () => save(),          // ⌘K⌘S on Mac, Ctrl+K Ctrl+S elsewhere
  'mod+shift+p': () => openPalette(),
  'g g':         () => goToTop(),
  esc:           { handler: closePanel, when: () => isPanelOpen() },
  space:         { handler: togglePlay, trigger: 'keyup' },
}, { modKey: 'ctrl' }); // explicit platform for tests / SSR

const unmount = map.mount(document);

// Dynamic bindings:
const unbind = map.bind('ctrl+z', () => undo());
unbind(); // or: map.unbind('ctrl+z')

// Display helper:
formatShortcut('mod+shift+p', 'meta'); // '⇧⌘P'
formatShortcut('mod+shift+p', 'ctrl'); // 'Ctrl+Shift+P'

// Cleanup:
unmount();     // remove from this target only
map.dispose(); // or: using map = createKeymap(…)

Keymap layers

Stack keymaps for modal UI. Mount the base and the layer independently — each manages its own listeners:

import { createKeymap, createKeymapLayer } from '@vielzeug/keymap';

const base = createKeymap({ 'ctrl+z': undo });
const modal = createKeymapLayer(base, {
  esc: { handler: closeModal, when: () => isModalOpen() },
});

const unmountBase = base.mount(document);
const unmountModal = modal.mount(document);

modal.deactivate(); // base handles everything; layer is suspended
modal.activate();   // layer takes over again

modal.parent === base; // true — parent reference is accessible

unmountModal();
unmountBase();

Full docs →