{"id":20033928,"url":"https://github.com/liorp/react-hotkeys-docs-hook","last_synced_at":"2026-06-06T18:31:28.214Z","repository":{"id":79053147,"uuid":"455602929","full_name":"liorp/react-hotkeys-docs-hook","owner":"liorp","description":null,"archived":false,"fork":false,"pushed_at":"2022-02-05T10:12:14.000Z","size":32560,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T05:44:21.609Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"react-hotkeys-docs-hook.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liorp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-04T15:42:19.000Z","updated_at":"2022-02-04T21:10:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"109ca622-7917-42c1-9dcc-b700b30bfa3f","html_url":"https://github.com/liorp/react-hotkeys-docs-hook","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/liorp/react-hotkeys-docs-hook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liorp%2Freact-hotkeys-docs-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liorp%2Freact-hotkeys-docs-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liorp%2Freact-hotkeys-docs-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liorp%2Freact-hotkeys-docs-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liorp","download_url":"https://codeload.github.com/liorp/react-hotkeys-docs-hook/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liorp%2Freact-hotkeys-docs-hook/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33995625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-06T02:00:07.033Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T09:48:00.116Z","updated_at":"2026-06-06T18:31:28.197Z","avatar_url":"https://github.com/liorp.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-hotkeys-docs-hook\n\n![GitHub](https://img.shields.io/github/license/liorp/react-hotkeys-docs-hook)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/react-hotkeys-docs-hook)\n[![react-docs-hotkeys-hook example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-docs-hotkeys-hook-example-87ifc?fontsize=14\u0026hidenavigation=1\u0026theme=dark)\n\nThis is a thin wrapper for [react-hotkeys-hook](https://react-hotkeys-hook.vercel.app/) package to allow dynamically documenting the hotkeys.\nThis means that the every hotkey that a component registers is added to a global context, and removed from the context upon the component unmount, to ensure fresh list of hotkeys.\n\n## Documentation\n\n- [Quick Start](https://react-hotkeys-docs-hook.vercel.app/docs/intro)\n- [API](https://react-hotkeys-docs-hook.vercel.app/docs/api/useHotkeysDocs)\n\n## Installation\n\n```shell\nnpm install react-hotkeys-docs-hook\n```\n\nor\n\n```shell\nyarn add react-hotkeys-docs-hook\n```\n\nMake sure that you have at least version 16.8 of `react` and `react-dom` installed, or otherwise hooks won't work for you.\n\n## Usage\n\n```ts\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport {\n  useHotkeysDocs,\n  useHotkeysDocsContext,\n  HotkeysDocsContext,\n  Hotkey,\n} from 'react-hotkeys-docs-hook';\n\nconst InnerSection = () =\u003e {\n  useHotkeysDocs('A', 'Cool hotkey', 'b', () =\u003e\n    console.log('Cool hotkey called!')\n  );\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003eSection A\u003c/h1\u003eLorem\n    \u003c/div\u003e\n  );\n};\n\nconst AnotherInnerSection = () =\u003e {\n  useHotkeysDocs('B', 'Another cool hotkey', 'a', () =\u003e\n    console.log('Another cool hotkey called!')\n  );\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003eSection B\u003c/h1\u003eIpsum\n    \u003c/div\u003e\n  );\n};\n\nexport const HotkeysDocs = () =\u003e {\n  const { hotkeysDocs } = useHotkeysDocsContext();\n  const sections = hotkeysDocs.map(v =\u003e v.section);\n  return (\n    \u003cdiv\u003e\n      {sections.map(s =\u003e (\n        \u003cdiv key={s}\u003e\n          \u003ch2\u003e{s}\u003c/h2\u003e\n          {hotkeysDocs\n            .filter(v =\u003e v.section === s)\n            .map(k =\u003e (\n              \u003cspan key={k.keys}\u003e\n                \u003cpre\u003e{k.keys}\u003c/pre\u003e\n                {k.description}\n              \u003c/span\u003e\n            ))}\n        \u003c/div\u003e\n      ))}\n      {!hotkeysDocs \u0026\u0026 'No hotkeys available'}\n    \u003c/div\u003e\n  );\n};\n\nconst App = () =\u003e {\n  const [hotkeysDocs, setHotkeysDocs] = React.useState\u003cHotkey\u003e([]);\n\n  return (\n    \u003cHotkeysDocsContext.Provider value={{ hotkeysDocs, setHotkeysDocs }}\u003e\n      \u003cHotkeysDocs /\u003e\n      \u003cbr /\u003e\n      \u003cInnerSection /\u003e\n      \u003cAnotherInnerSection /\u003e\n    \u003c/HotkeysDocsContext.Provider\u003e\n  );\n};\n```\n\n### Call Signature\n\n```ts\nfunction useHotkeyDocs\u003cT extends Element\u003e(\n  section: string,\n  description: string,\n  keys: string,\n  callback: (event: KeyboardEvent, handler: HotkeysEvent) =\u003e void,\n  options: Options = {},\n  deps: any[] = []\n): React.MutableRef\u003cT | null\u003e;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliorp%2Freact-hotkeys-docs-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliorp%2Freact-hotkeys-docs-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliorp%2Freact-hotkeys-docs-hook/lists"}