RepositoryJavaScriptCACanada
RobertWHurst

RobertWHurst/KeyboardJS

A JavaScript library for binding keyboard combos without the pain of key codes and key combo conflicts.

2.1kstars
221forks
0issues
0views

🎹 KeyboardJS: Pain-Free Keyboard Binding in JavaScript

Bind keyboard shortcuts without memorizing key codes or fighting combo conflicts.

KeyboardJS by Robert Hurst is a JavaScript library for browser and node.js that lets developers bind keyboard actions without dealing with messy key codes. It handles simple keys, combinations, sequences, and modifier keys like alt, shift, and ctrl. With US locale default, custom locale support, and context system for single-page applications, it's a practical tool for web key handling. Note: the author recommends checking out their newer library Keystrokes for new projects.

✨ Highlights

  • Key combos without key codes: bind using readable strings like 'a + b' or 'alt + shift > c'
  • Contexts for SPAs: scope bindings to specific application views
  • Custom locale support: create keyboard layouts beyond US default
  • Press/release distinction: separate handlers for keydown and keyup, or use bindPress/bindRelease
  • Prevent keydown repeat: e.preventRepeat() stops repeated calls when holding a key
  • Pause, resume, reset: control binding state, clear everything with reset()
  • Programmatic key simulation: pressKey, releaseKey, releaseAllKeys for testing
  • TypeScript ready: ships with its own types, no @types needed

💡 Why it matters

KeyboardJS solves the common frustration of working with raw keyboard events in JavaScript. Instead of managing numeric key codes and handling combo conflicts manually, developers can use human-readable strings. The context system is particularly useful for SPAs where different views need different shortcuts. While the author now points to Keystrokes as a more refined alternative, KeyboardJS remains a solid, well-documented option with a proven track record (2k+ stars) and features like sequence binding ('a + b > c') that are rare in similar libraries.


#JavaScript #KeyboardEvents #WebDevelopment #OpenSource #TiniX

Similar Projects

Discover other similar projects and AI models.

RepositoryTypeScript
RobertWHurst/Keystrokes

Keystrokes as an easy to use library for binding functions to keys and key combos. It can be used with any TypeScript or JavaScript project, even in non-browser environments.

193
Nov 17, 2026
RepositoryJavaScript
react/react

The library for web and native user interfaces.

253.0k
Nov 30, 2026
RepositoryJavaScript
trekhleb/javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings

196.8k
Jul 26, 2026
RepositoryTypeScript
morluto/rea

Reverse engineer anything with agents, from app behavior down to native binaries.

487.0k
Dec 2, 2026
RepositoryTypeScript
freeCodeCamp/freeCodeCamp

freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.

459.9k
Dec 2, 2026
RepositoryPython
practical-tutorials/project-based-learning

Curated list of project-based tutorials

290.9k
Nov 30, 2026
RepositoryTypeScript
vuejs/vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

212.6k
Oct 10, 2024
Repository
getify/You-Dont-Know-JS

A book series (2 published editions) on the JS language.

184.8k
Oct 31, 2026
RepositoryJavaScript
ccampbell/mousetrap

Simple library for handling keyboard shortcuts in Javascript

11.8k
Mar 15, 2023