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

hotkey-hint

v1.0.3

Published

Keyboard shortcut manager with a beautiful overlay. Register hotkeys, reveal them with ?, handle sequences and groups — in 5 lines. Zero dependencies.

Downloads

267

Readme

⌨️ hotkey-hint

Keyboard shortcut manager with a beautiful overlay. Register hotkeys, reveal them with ?, handle sequences and groups — in 5 lines. Zero dependencies.

npm version npm downloads bundle size license TypeScript zero dependencies

Live Demo →


Why

Every power-user app — GitHub, Figma, Linear, Notion — has a keyboard shortcut layer that reveals itself when you press ?. Building one from scratch means wiring up event listeners, handling modifier keys, managing sequences like g then h, grouping shortcuts by category, and building a UI on top of all that.

hotkey-hint does all of that for you.


Install

npm install hotkey-hint
# or
yarn add hotkey-hint
# or
pnpm add hotkey-hint

Quick Start

import HotkeyHint from 'hotkey-hint';

const hh = new HotkeyHint({ theme: 'auto' });

hh.registerAll([
  {
    keys: 'ctrl+k',
    description: 'Open command palette',
    action: () => openCommandPalette(),
  },
  {
    keys: 'ctrl+s',
    description: 'Save document',
    action: () => save(),
  },
]);

// That's it. Press ? to open the overlay.

Features

  • Zero dependencies — pure TypeScript, no external packages
  • Beautiful overlay — press ? to show all registered shortcuts, grouped and labeled
  • Sequence shortcuts — vim-style g then h sequences with a 2s timeout
  • Groups — organize shortcuts by category (Navigation, Editor, etc.)
  • Themesdark, light, or auto (follows prefers-color-scheme)
  • Smart modifier detection — handles ctrl, shift, alt, meta/cmd cross-platform
  • Skips inputs — never fires inside <input>, <textarea>, or contenteditable
  • Chainable API.register().register().registerAll()
  • SSR safe — guards all DOM access behind typeof window
  • ~3kB minified + gzipped

API

new HotkeyHint(options?)

| Option | Type | Default | Description | |--------|------|---------|-------------| | triggerKey | string | "?" | Key that opens the overlay | | theme | "dark" \| "light" \| "auto" | "auto" | Color theme | | position | "center" \| "bottom-right" \| "bottom-left" | "center" | Panel position | | title | string | "Keyboard Shortcuts" | Overlay heading | | zIndex | number | 9999 | CSS z-index |

Instance methods

| Method | Returns | Description | |--------|---------|-------------| | .register(hotkey) | this | Register a single hotkey | | .registerAll(hotkeys[]) | this | Register multiple hotkeys | | .unregister(keys) | this | Remove a hotkey by key string | | .show() | void | Open the overlay programmatically | | .hide() | void | Close the overlay | | .toggle() | void | Show/hide | | .destroy() | void | Remove all listeners and DOM elements |

HotkeyDefinition

interface HotkeyDefinition {
  keys: string;           // "ctrl+k", "shift+?", "g then h"
  description: string;    // shown in the overlay
  action: () => void;     // called when shortcut fires
  group?: string;         // groups shortcuts in the overlay (default: "General")
  preventDefault?: boolean; // default: true
}

Examples

With groups

hh.registerAll([
  { keys: 'g then h', description: 'Go home',       group: 'Navigation', action: goHome },
  { keys: 'g then p', description: 'Go to profile', group: 'Navigation', action: goProfile },

  { keys: 'ctrl+b',   description: 'Bold',      group: 'Editor', action: bold },
  { keys: 'ctrl+i',   description: 'Italic',    group: 'Editor', action: italic },
]);

Sequence shortcuts (vim-style)

hh.register({
  keys: 'g then s',
  description: 'Go to settings',
  group: 'Navigation',
  action: () => router.push('/settings'),
});

React hook

import { useEffect } from 'react';
import HotkeyHint from 'hotkey-hint';

function useHotkeys(hotkeys: HotkeyDefinition[], deps: any[] = []) {
  useEffect(() => {
    const hh = new HotkeyHint({ theme: 'auto' });
    hh.registerAll(hotkeys);
    return () => hh.destroy();
  }, deps);
}

Programmatic control

// Show/hide from anywhere
document.getElementById('help-btn').addEventListener('click', () => hh.show());

// Dynamically add/remove
hh.register({ keys: 'ctrl+p', description: 'Print', action: print });
hh.unregister('ctrl+p');

CDN (no build step)

<script type="module">
  import HotkeyHint from 'https://esm.sh/hotkey-hint';
  const hh = new HotkeyHint();
  hh.register({ keys: 'ctrl+k', description: 'Search', action: openSearch });
</script>

Supported Key Syntax

| Input | Rendered (Mac) | Rendered (Win/Linux) | |-------|---------------|----------------------| | ctrl+k | ⌃K | Ctrl+K | | cmd+shift+p | ⌘⇧P | Ctrl+⇧P | | alt+t | ⌥T | Alt+T | | g then h | G then H | G then H | | escape | Esc | Esc | | shift+? | ⇧? | ⇧? |


Customization

Override CSS variables to theme the overlay:

.hh-modal {
  --hh-bg: #0f172a;
  --hh-text: #f8fafc;
  --hh-border: rgba(255,255,255,0.06);
  --hh-key-bg: #1e293b;
  --hh-key-border: rgba(255,255,255,0.1);
  --hh-key-text: #e2e8f0;
  --hh-group-title: rgba(255,255,255,0.35);
  --hh-row-hover: rgba(255,255,255,0.03);
  --hh-footer: rgba(255,255,255,0.25);
}

License

MIT