{"id":15664684,"url":"https://github.com/dzucconi/use-keyboard-list-navigation","last_synced_at":"2025-04-14T16:23:04.614Z","repository":{"id":37056674,"uuid":"238525086","full_name":"dzucconi/use-keyboard-list-navigation","owner":"dzucconi","description":"A React hook to navigate through lists with your keyboard","archived":false,"fork":false,"pushed_at":"2023-12-14T20:57:19.000Z","size":2086,"stargazers_count":16,"open_issues_count":27,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T05:06:31.010Z","etag":null,"topics":["keyboard","react","react-hook","react-hooks","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/use-keyboard-list-navigation","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/dzucconi.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":"2020-02-05T18:56:40.000Z","updated_at":"2024-04-16T19:50:35.000Z","dependencies_parsed_at":"2024-06-18T22:46:45.868Z","dependency_job_id":"65678092-cdd5-4a6b-9277-24753e9d289a","html_url":"https://github.com/dzucconi/use-keyboard-list-navigation","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzucconi%2Fuse-keyboard-list-navigation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzucconi%2Fuse-keyboard-list-navigation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzucconi%2Fuse-keyboard-list-navigation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzucconi%2Fuse-keyboard-list-navigation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dzucconi","download_url":"https://codeload.github.com/dzucconi/use-keyboard-list-navigation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248914566,"owners_count":21182439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["keyboard","react","react-hook","react-hooks","typescript"],"created_at":"2024-10-03T13:43:52.719Z","updated_at":"2025-04-14T16:23:04.589Z","avatar_url":"https://github.com/dzucconi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-keyboard-list-navigation\n\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![npm](https://img.shields.io/npm/v/use-keyboard-list-navigation)](https://www.npmjs.com/package/use-keyboard-list-navigation) [![Build Status](https://travis-ci.com/dzucconi/use-keyboard-list-navigation.svg?branch=master)](https://app.travis-ci.com/github/dzucconi/use-keyboard-list-navigation)\n\n## What is this?\n\nA React hook to navigate through lists with your keyboard.\n\n## Installation\n\n```bash\nyarn add use-keyboard-list-navigation\n```\n\n## Usage\n\n```javascript\nimport React from \"react\";\nimport { useKeyboardListNavigation } from \"use-keyboard-list-navigation\";\n\nconst App: React.FC = () =\u003e {\n  const list = [\"one\", \"two\", \"three\"];\n\n  const { index, cursor, interactive, selected } = useKeyboardListNavigation({\n    list,\n    onEnter: console.log.bind(console),\n  });\n\n  return (\n    \u003cpre\u003e\n      \u003ccode\u003e{JSON.stringify({ index, cursor, interactive, selected })}\u003c/code\u003e\n    \u003c/pre\u003e\n  );\n};\n```\n\n## Interface\n\n```typescript\ntype UseKeyboardListNavigationProps\u003cT\u003e = {\n  ref?: React.MutableRefObject\u003cany\u003e | undefined;\n  list: T[];\n  waitForInteractive?: boolean | undefined;\n  defaultValue?: T | undefined;\n  bindAxis?: \"vertical\" | \"horizontal\" | \"both\" | undefined;\n  onEnter({\n    event,\n    element,\n    state,\n    index,\n  }: {\n    event: KeyboardEvent;\n    element: T;\n    state: UseKeyboardListNavigationState;\n    index: number;\n  }): void;\n  extractValue?(item: T): string;\n};\n\nconst useKeyboardListNavigation: \u003cT\u003e({\n  ref,\n  list,\n  waitForInteractive,\n  defaultValue,\n  onEnter,\n  extractValue,\n}: UseKeyboardListNavigationProps\u003cT\u003e) =\u003e {\n  index: number;\n  selected: T;\n  cursor: number;\n  length: number;\n  interactive: boolean;\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzucconi%2Fuse-keyboard-list-navigation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdzucconi%2Fuse-keyboard-list-navigation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzucconi%2Fuse-keyboard-list-navigation/lists"}