whatisgithub

What is hotkeys-js?

jaywcjlove/hotkeys-js — explained in plain English

Analysis updated 2026-06-22

7,098TypeScriptAudience · developerComplexity · 1/5Setup · easy

In one sentence

A tiny 8KB JavaScript library for adding keyboard shortcuts like Ctrl+S or Shift+A to web apps, with scope grouping so the same key does different things in different parts of your app.

Mindmap

mindmap
  root((hotkeys-js))
    What it does
      Keyboard shortcuts
      Scope grouping
      Modifier detection
    Tech Stack
      TypeScript
      JavaScript
      npm
    Features
      No dependencies
      8KB bundle size
      Enable and disable
    Use Cases
      Editor shortcuts
      App navigation
      Custom key combos
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add Ctrl+S to save and Ctrl+Z to undo in a browser-based editor without a heavy keyboard library.

USE CASE 2

Create scope groups so pressing the same key does different things depending on which panel or modal is active.

USE CASE 3

Query which modifier keys the user is holding right now to build custom multi-key interaction logic.

USE CASE 4

Enable and disable individual shortcuts dynamically as the user navigates between sections of your app.

What is it built with?

TypeScriptJavaScriptnpm

How does it compare?

jaywcjlove/hotkeys-jscivitai/civitaicompanion-inc/feynman
Stars7,0987,1077,088
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasyhardmoderate
Complexity1/54/53/5
Audiencedeveloperdeveloperresearcher

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Install via npm or use a plain script tag, no config, bundler, or build setup required.

So what is it?

Hotkeys.js is a small JavaScript library for detecting keyboard shortcuts in a web browser. It lets developers define combinations like Ctrl+S or Shift+A and run code when a user presses them. The library has no external dependencies and is tiny in size, around 8 kilobytes, so it adds almost no weight to a web page. Using it is straightforward: you call a single function with the key combination you want to watch for and a callback function that runs when that combination is pressed. You can define multiple shortcuts for the same action, and you can turn individual shortcuts on and off without removing them. The library also supports a scope system, which means you can group shortcuts by name and switch between groups, so pressing the same key does different things depending on which part of your app is active. The library understands modifier keys like Command, Control, Shift, Option, and Alt, and it can tell which of them are currently held down at any moment. It also provides a way to query which keys are pressed right now, not just react to combinations. Hotkeys.js works in all major browsers and can be loaded via a standard script tag or pulled in through the npm package manager used by Node-based build tools. The README includes short code samples for common use cases and links to a documentation site. The project is open source and maintained by an independent developer.

Copy-paste prompts

Prompt 1
How do I add a Ctrl+S keyboard shortcut to my web app using hotkeys-js and trigger a save function when pressed?
Prompt 2
I have a modal and a main view that need different keyboard shortcuts for the same keys. How do I use hotkeys-js scopes to switch between them?
Prompt 3
How do I detect if the user is holding Shift and Command at the same time using hotkeys-js?
Prompt 4
Show me how to install hotkeys-js via npm and import it into a TypeScript project with the correct type definitions.
Prompt 5
How do I temporarily disable a keyboard shortcut I registered with hotkeys-js and then re-enable it later?

Frequently asked questions

What is hotkeys-js?

A tiny 8KB JavaScript library for adding keyboard shortcuts like Ctrl+S or Shift+A to web apps, with scope grouping so the same key does different things in different parts of your app.

What language is hotkeys-js written in?

Mainly TypeScript. The stack also includes TypeScript, JavaScript, npm.

How hard is hotkeys-js to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is hotkeys-js for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.