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

@buildwithdarsh/keyboardjs

v1.0.0

Published

A tiny, modular keyboard input library — hotkeys, sequences, chords, scopes, layouts, recorder

Readme

This project is made with the help of Claude (1M context).

KeyBoardJS

The tiny keyboard library.

Hotkeys, sequences, chords, scopes, layouts, and a recorder — all in one script tag. Zero dependencies, TypeScript first.


Why KeyBoardJS?

| | hotkeys-js | Mousetrap | KeyBoardJS | |---|---|---|---| | Hotkeys | Yes | Yes | Yes | | Key sequences (g g) | No | Yes | Yes | | Chords (hold j+k) | No | No | Yes | | Named scopes | Partial | No | Yes (stackable) | | Layout remap (Dvorak/Colemak) | No | No | Yes | | Record + replay | No | No | Yes | | TypeScript-first | No | No | Yes | | Gzip size | ~3KB | ~3KB | ~4KB (everything) |


Quick Start

<script src="https://keyboardjs.work.withdarsh.com/dist/keyboard.umd.js"></script>
<script>
  Keyboard.init();

  Keyboard.on('ctrl+k', () => openPalette());
  Keyboard.on(['g', 'g'], () => window.scrollTo(0, 0));
  Keyboard.chord(['j', 'k'], () => exitInsertMode());
</script>

Or with a bundler:

import Kb from 'KeyBoardJS';

Kb.init();
Kb.on('shift+?', () => showHelp());

API

Kb.init(opts?)

Attach listeners to window (or a custom EventTarget).

Kb.on(combo, handler, opts?)

Register a hotkey. Accepts 'ctrl+k' style strings.

Kb.on('ctrl+shift+p', (e) => { ... }, {
  scope: 'editor',      // only fire in this scope
  allowInInput: false,  // ignore when typing in inputs
  preventDefault: true, // stop default browser behaviour
});

Kb.on([k1, k2, ...], handler, opts?)

Register a sequence. Fires when keys are pressed in order within timeout ms.

Kb.on(['g', 'g'], gotoTop, { timeout: 800 });

Kb.chord([k1, k2, ...], handler, opts?)

Register a chord — keys pressed simultaneously within window ms.

Kb.chord(['j', 'k'], exitInsertMode, { window: 200 });

Scopes

Kb.scope('editor');          // activate
Kb.scope();                  // read current
const pop = Kb.pushScope('modal');
pop();                       // restore previous

Bindings with scope: 'global' always fire. Others only fire in the active scope.

Layouts

Kb.layout('dvorak'); // or 'colemak' | 'qwerty'

Recorder

Kb.record();
// ... user types ...
const frames = Kb.stop();
await Kb.replay(frames, 2); // 2x speed

Misc

Kb.off('ctrl+k');    // remove
Kb.clear();          // remove all
Kb.list();           // [{ combo, scope }, ...] — good for help dialogs
Kb.format('ctrl+k'); // "Ctrl + K"

Platform support (Mac / Windows / Linux)

Use mod (a.k.a. cmdOrCtrl) for bindings that should work the same on every OS:

Kb.on('mod+k', openPalette);   // ⌘K on Mac, Ctrl+K on Windows/Linux
Kb.on('mod+shift+p', command); // ⇧⌘P / Ctrl+Shift+P

Inspect the detected platform:

Kb.platform   // 'mac' | 'windows' | 'linux' | 'other'
Kb.isMac      // true on macOS / iPadOS / iOS
Kb.modKey     // 'meta' (Mac) or 'control' (PC)
Kb.format('mod+shift+k')  // "⇧⌘K" on Mac, "Ctrl + Shift + K" on PC

Kb.format() returns Mac glyphs (⌘ ⌥ ⇧ ⌃ ↵ ⌫ ⇥) on Apple platforms and word labels (Ctrl + Shift + K) elsewhere — drop straight into tooltips and help dialogs.

Key names

Case-insensitive. Aliases supported:

  • mod / cmdOrCtrl / commandOrControlplatform-aware (Cmd on Mac, Ctrl elsewhere)
  • ctrl / control
  • cmd / meta / command / win
  • alt / option / opt
  • esc / escape
  • return / enter
  • space / spacebar
  • up / down / left / right (arrow keys)
  • pgup / pgdn, del, ins

License

MIT © Darsh Gupta