{"id":18850795,"url":"https://github.com/luqmanoop/use-kbd-list","last_synced_at":"2026-05-01T10:32:33.234Z","repository":{"id":166926351,"uuid":"640524650","full_name":"luqmanoop/use-kbd-list","owner":"luqmanoop","description":"Add full keyboard navigation support to your list component","archived":false,"fork":false,"pushed_at":"2023-05-21T20:31:34.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T22:01:09.778Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://use-kbd-list.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/luqmanoop.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","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":"2023-05-14T11:37:22.000Z","updated_at":"2023-05-18T17:04:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"10b721e1-c4fc-4de7-a791-d1a1dcca9588","html_url":"https://github.com/luqmanoop/use-kbd-list","commit_stats":null,"previous_names":["codeshifu/use-kbd-list","luqmanoop/use-kbd-list"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/luqmanoop/use-kbd-list","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luqmanoop%2Fuse-kbd-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luqmanoop%2Fuse-kbd-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luqmanoop%2Fuse-kbd-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luqmanoop%2Fuse-kbd-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luqmanoop","download_url":"https://codeload.github.com/luqmanoop/use-kbd-list/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luqmanoop%2Fuse-kbd-list/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32494270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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-08T03:31:41.535Z","updated_at":"2026-05-01T10:32:33.208Z","avatar_url":"https://github.com/luqmanoop.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-kbd-list\n\n\u003e Add full keyboard navigation support to your list components\n\nAdd `ArrowDown`, `ArrowUp`, `PageDown`, `PageUp`, `Home` \u0026 `End` keyboard support w/ smooth scrolling to your list component.\n\nLive demo https://use-kbd-list.vercel.app\n\n\u003cimg src=\"https://raw.githubusercontent.com/codeshifu/assets/main/gifs/use-kbd-list.gif\" alt=\"use-kbd-list\" width=\"640\" /\u003e\n\n## Install\n\n```sh\nnpm install use-kbd-list\n```\n\n## Example\n\n```tsx\nimport { useKbdList } from \"use-kbd-list\";\n\nfunction App() {\n  const {\n    ref, // scroll container ref\n    activeIndex, // index of the element navigated to\n    activeElement, // element navigated to\n    handleLeave, // handler function for the scroll container onMouseLeave, onPointerLeave event\n    handleMove // handler function for the list item onMouseMove, onPointerMove event\n  } = useKbdList\u003cHTMLUListElement\u003e(myList.length, \"data-index\");\n\n  console.log(activeElement?.textContent);\n\n  return (\n    \u003cul ref={ref} onMouseLeave={handleLeave} onPointerLeave={handleLeave}\u003e\n      {myList.map((item, index) =\u003e (\n        \u003cli\n          key={item}\n          onMouseMove={handleMove}\n          onPointerMove={handleMove}\n          data-index={index}\n          style={{\n            backgroundColor: activeIndex === index ? \"#eceef4\" : \"transparent\"\n          }}\n        \u003e\n          {item}\n        \u003c/li\u003e\n      ))}\n    \u003c/ul\u003e\n  );\n}\n```\n\n## API\n\n`useKbdList\u003cT\u003e(listLength, listItemIndexAttribute, options)`\n\n### listLength\n\nThe length of your list e.g. `users.length`\n\nType: `number`\n\nRequired: `true`\n\n### listItemIndexAttribute\n\nThe name of an attribute set on the list item. You could use anything else other `data-index` as the attribute name\n\nNOTE: **The value of this attribute must be the index of the list item in the list** e.g.\n\n```tsx\nconst App = () =\u003e {\n  useKbdList(items, \"data-index\");\n\n  ...\n\n  return (\n    \u003cul\u003e\n      {items.map((item, index) =\u003e (\n        \u003cli key={item} data-index={index}\u003e\n          {item}\n        \u003c/li\u003e\n      ))}\n    \u003c/ul\u003e\n  );\n};\n```\n\n### options\n\n`react-hotkeys-hooks` [options](https://github.com/JohannesKlauss/react-hotkeys-hook#options)\n\nType: `object`\n\nRequired: `false`\n\nE.g. If you want the hook to run while an input is focused, like in a ComboBox\n\n```tsx\nuseKbdList\u003cHTMLUListElement\u003e(myList.length, \"data-index\", {\n  enableOnFormTags: true\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluqmanoop%2Fuse-kbd-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluqmanoop%2Fuse-kbd-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluqmanoop%2Fuse-kbd-list/lists"}