tinykeys

A tiny (~400 B) & modern library for keybindings. See on GitHub

npm install tinykeys

Examples

Try one of the following:

import tinykeys from "tinykeys"

tinykeys(window, {
  "Shift+D": () => {
    alert("The 'Shift' and 'd' keys were pressed at the same time")
  },
  "y e e t": () => {
    alert("The keys 'y', 'e', 'e', and 't' were pressed in order")
  },
  "$mod+KeyD": () => {
    alert("Either 'Control+d' or 'Meta+d' were pressed")
  },
})

History

Logs KeyboardEvent.key and KeyboardEvent.code used by this library

(start typing)