UNPKG

@tanstack/hotkeys

Version:

Type-safe, framework-agnostic keyboard hotkey management for the browser

141 lines (117 loc) • 6.6 kB
<div align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/api/readme/hotkeys.png?theme=dark" /> <source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/api/readme/hotkeys.png" /> <img src="https://tanstack.com/api/readme/hotkeys.png" alt="TanStack Hotkeys" width="900" /> </picture> </div> <br /> <div align="center"> <a href="https://www.npmjs.com/package/@tanstack/hotkeys" target="\_parent"> <img alt="" src="https://img.shields.io/npm/dm/@tanstack/hotkeys.svg" alt="npm downloads" /> </a> <a href="https://github.com/TanStack/hotkeys" target="\_parent"> <img alt="" src="https://img.shields.io/github/stars/TanStack/hotkeys.svg?style=social&label=Star" alt="GitHub stars" /> </a> <a href="https://bundlephobia.com/result?p=@tanstack/react-hotkeys@latest" target="\_parent"> <img alt="" src="https://badgen.net/bundlephobia/minzip/@tanstack/react-hotkeys@latest" alt="Bundle size" /> </a> </div> <div align="center"> <a href="#badge"> <img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg"> </a> <a href="#badge"> <img src="https://img.shields.io/github/v/release/tanstack/hotkeys" alt="Release"/> </a> <a href="https://twitter.com/tan_stack"> <img src="https://img.shields.io/twitter/follow/tan_stack.svg?style=social" alt="Follow @TanStack"/> </a> </div> <div align="center"> ### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/) </div> # TanStack Hotkeys > [!NOTE] > TanStack Hotkeys is in beta. We are actively developing the library and are open to feedback and contributions. Type-safe keyboard shortcuts for the web. Template-string bindings, parsed objects, a cross-platform `Mod` key, a singleton Hotkey Manager, and utilities for cheatsheet UIs—built to stay SSR-friendly. - Type-safe bindings — template strings (`Mod+Shift+S`, `Escape`) or parsed objects for full control - Flexible options — `keydown`/`keyup`, `preventDefault`, `stopPropagation`, conditional enabled, `requireReset` - Cross-platform Mod — maps to Cmd on macOS and Ctrl on Windows/Linux - Batteries included — validation + matching, sequences (Vim-style), key-state tracking, recorder UI helpers, framework adapters, and devtools ### <a href="https://tanstack.com/hotkeys">Read the docs →</a> <br /> > [!NOTE] > You may know **TanStack Hotkeys** by our adapter names, too! > > - [**Alpine Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/alpine/quick-start) > - [**Ember Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/ember/quick-start) > - [**Octane Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/octane/quick-start) > - [**React Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/react/react-hotkeys) > - [**Preact Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/preact/preact-hotkeys) > - [**Solid Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/solid/reference) > - [**Angular Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/angular/reference) > - [**Vue Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/vue/reference) > - [**Lit Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/lit/reference) > - [**Svelte Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/svelte/reference) ## Get Involved - We welcome issues and pull requests! - Participate in [GitHub discussions](https://github.com/TanStack/hotkeys/discussions) - Chat with the community on [Discord](https://discord.com/invite/WrRKjPJ) - See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions ## Partners <div align="center"> <table align="center"> <tr> <td> <a href="https://www.coderabbit.ai/?via=tanstack&dub_id=aCcEEdAOqqutX6OS" > <picture> <source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/coderabbit-dark-D643Zkrv.svg" height="40" /> <source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/coderabbit-light-CIzGLYU_.svg" height="40" /> <img src="https://tanstack.com/assets/coderabbit-light-DVMJ2jHi.svg" height="40" alt="CodeRabbit" /> </picture> </a> </td> <td> <a href="https://www.cloudflare.com?utm_source=tanstack"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/cloudflare-white-Co-Tyjbl.svg" height="60" /> <source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/cloudflare-black-6Ojsn8yh.svg" height="60" /> <img src="https://tanstack.com/assets/cloudflare-black-CPufaW0B.svg" height="60" alt="Cloudflare" /> </picture> </a> </td> </tr> </table> <div align="center"> <img src="media/partner_logo.svg" alt="Keys & you?" height="65"> <p> We're looking for TanStack Hotkeys Partners to join our mission! Partner with us to push the boundaries of TanStack Hotkeys and build amazing things together. </p> <a href="mailto:partners@tanstack.com?subject=TanStack Hotkeys Partnership"><b>LET'S CHAT</b></a> </div> </div> ## Explore the TanStack Ecosystem - <a href="https://github.com/tanstack/config"><b>TanStack Config</b></a> – Tooling for JS/TS packages - <a href="https://github.com/tanstack/db"><b>TanStack DB</b></a> – Reactive sync client store - <a href="https://github.com/tanstack/devtools"><b>TanStack DevTools</b></a> – Unified devtools panel - <a href="https://github.com/tanstack/form"><b>TanStack Form</b></a> – Type‑safe form state - <a href="https://github.com/tanstack/hotkeys"><b>TanStack Hotkeys</b></a> – Type‑safe keyboard shortcuts - <a href="https://github.com/tanstack/query"><b>TanStack Query</b></a> – Async state & caching - <a href="https://github.com/tanstack/ranger"><b>TanStack Ranger</b></a> – Range & slider primitives - <a href="https://github.com/tanstack/router"><b>TanStack Router</b></a> – Type‑safe routing, caching & URL state - <a href="https://github.com/tanstack/start"><b>TanStack Start</b></a> – Full‑stack SSR & streaming - <a href="https://github.com/tanstack/store"><b>TanStack Store</b></a> – Reactive data store - <a href="https://github.com/tanstack/table"><b>TanStack Table</b></a> – Headless datagrids - <a href="https://github.com/tanstack/virtual"><b>TanStack Virtual</b></a> – Virtualized rendering … and more at <a href="https://tanstack.com"><b>TanStack.com »</b></a>