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

webhotkeys

v1.1.1

Published

Easy solution to integrate keyboard hotkeys into the webpage.

Readme

WebHotkeys

Easy solution to integrate keyboard hotkeys into the webpage.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/WebHotkeys.min.js"
        integrity="sha384-GSvmX7qIMnxd5kgPsLoA3YzwUaZQcKBmCh66PVPZNibhc4VRxD+6h61FyJd3/gD9"
        crossorigin="anonymous" data-register></script>

Keep the crossorigin="anonymous" attribute – without it the browser refuses to verify the integrity hash and the script does not load at all. The hash belongs to that exact version, so copy the whole snippet as it is; a version bumped without the matching hash means the script silently stops loading.

While debugging, swap dist/WebHotkeys.min.js for src/WebHotkeys.js to get the readable source. It is a different file, hence a different hash – recompute it (openssl dgst -sha384 -binary src/WebHotkeys.js | openssl base64 -A) or leave the integrity attribute out of your local build.

Or install it from npm:

npm install webhotkeys
import WebHotkeys from "webhotkeys" // or: const WebHotkeys = require("webhotkeys")
const wh = new WebHotkeys()

Both ESM (import) and CommonJS (require) work and TypeScript definitions are bundled. Note the npm/bundler build does not auto-register on window.webHotkeys (there is no data-register attribute there) - create the instance yourself as shown above.

Examples

A tour through what the library can do. Each line is standalone, copy what you need.

const wh = window.webHotkeys // or: const wh = new WebHotkeys()

// Plain combinations. The last parameter is optional in every `grab` call.
wh.grab("Alt+s", "Save the form", () => form.submit())
wh.grab("?", "Show the help", () => wh.toggleHelp(true)) // no need to mention Shift for a symbol
wh.grab("Mod+k", "Search", openSearch)                 // Ctrl+k, but Cmd+k on a Mac

// A sequence, GitHub style: hit `g`, then `i`.
wh.grab("g i", "Go to issues", () => location.assign("/issues"))

// An element instead of a callback - it gets clicked (or focused, if it is a form field).
wh.grab("Alt+n", "Focus the note", "#note")

// Groups: enable or disable a whole screen worth of hotkeys at once.
const editing = wh.group("Editing", [
    ["Ctrl+b", "Bold", () => exec("bold")],
    ["Ctrl+i", "Italics", () => exec("italic")],
])
editing.disable()

// Housekeeping.
wh.toggleHints(true)   // badge every element having a hotkey, the Vimium way
wh.destroy()           // detach everything (SPA unmount)

Declaratively, without touching JavaScript at all:

<div data-hotkey-group="Navigation">
    <a href="/inbox" data-hotkey="g i" title="Go to the inbox">Inbox</a>
    <button data-hotkey="Alt+n" title="New message">New</button>
</div>

See the live example.

Documentation

Full API reference, options, keyboard layouts and migration notes: cz-nic.github.io/webhotkeys

License

LGPL-3.0-or-later