Changelog
0.3.0 Latest
Minor Changes
-
A rewrite of the API, with framework adapters, optional sequences and a new toolchain. Breaking: see “Migrating from 0.2” in the README.
Breaking changes
useShortcutter()is replaced bycreateShortcutter(), andeventTargetbytarget.- Shortcuts are strings such as
'ControlOrMeta+K'instead of key arrays:listen('Control+K', handler, { context, phases })instead oflisten('ctx', ['controlleft', 'k'], handler, PHASES.DOWN). PHASESis removed: phases are'down','press'and'up', or an array of them. The default is now'down'only (was down and press).- Handlers get
(event, { phase, shortcut, pattern, context, description })instead of(event, phase). setActiveContext()/getActiveContext()are replaced bycontexts.activate(...names),contexts.active()andcontexts.isActive(name).- Listeners are no longer removed on
unload: calldestroy()or pass asignal. 'down'no longer fires again for the keys left after one is released.
New
- Case- and order-insensitive shortcut strings with aliases (
Ctrl,Cmd,Option,Esc, …), left/right modifiers matched alike, andControlOrMeta(⌘ on macOS, Ctrl elsewhere). - Wildcards:
'Shift+Arrow*','Digit*','Key*','F*','Control+*'. descriptionon shortcuts andshortcuts()to build keyboard help screens;resolve()for platform keys.isPressed(),pressed(),subscribe()andobserve()for held keys and every key phase (key visualizers, games).- Optional key sequences (
'G I') fromshortcutter/sequences, also asdist/sequences.iife.js. - Input guard (form fields, contenteditable, IME),
preventDefaultoption, SSR-safe import,destroy()andsignal. - Framework adapters:
@shortcutter/react,@shortcutter/vue,@shortcutter/svelteand@shortcutter/solid, with sequence hooks.
Fixes
- Keys no longer stay pressed after Cmd on macOS, after switching windows or tabs, or after leaving the page; modifiers pressed or released outside the page are corrected from the event flags.
listen()no longer sorts the caller’s key array in place.
Package
- ESM, CommonJS and a minified
<script>build (window.Shortcutter), with types for both module systems; zero dependencies, tree-shakeable, under 3 kB gzipped.
0.2.0
Released 28 June 2022 (tag 0.2.0).
Patch Changes
- Upgrades the build and test dependencies. No changes to the API.
0.1.0
Released 21 September 2021 (tag 0.1.0).
Minor Changes
- First release:
useShortcutter()withlisten(),unlisten(), contexts (hasContext(),getActiveContext(),setActiveContext()) and key phases throughPHASES(DOWN,PRESS,UPand their combinations).