{"id":17747583,"url":"https://github.com/patrikmasiar/react-keyboard-key","last_synced_at":"2025-03-14T23:30:33.729Z","repository":{"id":43275157,"uuid":"346814527","full_name":"patrikmasiar/react-keyboard-key","owner":"patrikmasiar","description":"Container and hook with keyboard event listener.","archived":false,"fork":false,"pushed_at":"2022-03-10T15:58:42.000Z","size":345,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-15T05:48:57.005Z","etag":null,"topics":["node-module","npm","package","react","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-keyboard-key","language":"JavaScript","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/patrikmasiar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"massoprod"}},"created_at":"2021-03-11T19:29:09.000Z","updated_at":"2023-03-05T08:18:49.000Z","dependencies_parsed_at":"2022-08-24T21:20:24.354Z","dependency_job_id":null,"html_url":"https://github.com/patrikmasiar/react-keyboard-key","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikmasiar%2Freact-keyboard-key","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikmasiar%2Freact-keyboard-key/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikmasiar%2Freact-keyboard-key/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikmasiar%2Freact-keyboard-key/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrikmasiar","download_url":"https://codeload.github.com/patrikmasiar/react-keyboard-key/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221516846,"owners_count":16836231,"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":["node-module","npm","package","react","typescript"],"created_at":"2024-10-26T09:05:48.466Z","updated_at":"2024-10-26T09:05:48.942Z","avatar_url":"https://github.com/patrikmasiar.png","language":"JavaScript","funding_links":["https://github.com/sponsors/massoprod"],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/react-keyboard-key?style=plastic)](https://www.npmjs.com/package/react-keyboard-key)\n[![NPM](https://img.shields.io/npm/l/react-keyboard-key)](https://github.com/patrikmasiar/react-keyboard-key/blob/master/LICENSE)\n[![NPM](https://img.shields.io/npm/dy/react-keyboard-key?style=plastic)](https://www.npmjs.com/package/react-keyboard-key)\n\n# react-keyboard-key\nContainer and hook with keyboard event listener.\n\n## Usage\n\n#### Types\n```javascript\nkeyInfo: {\n  key: string | null;\n  code: string | null;\n  keyCode: number | null;\n  output: KeyboardEvent | null,\n};\naddKeyListener: () =\u003e void;\nremoveEventListener: () =\u003e void;\nonKeyDownCallback: (event: KeyboardEvent) =\u003e void;\n```\n\n### Container\n```javascript\nimport { KeyListenerContainer } from 'react-keyboard-key';\n\n...\n\nconst ExampleComponent: FC\u003cProps\u003e = ({ children }) =\u003e {\n  return (\n    \u003cKeyListenerContainer\n      onKeyDownCallback={e =\u003e {\n        e.preventDefault();\n      }}\n    \u003e\n      {keyInfo =\u003e (\n        \u003cdiv\u003e\n          {keyInfo.code}\n        \u003c/div\u003e\n      )}\n    \u003c/KeyListenerContainer\u003e\n  );\n};\n\n```\n\n### Hook\n```javascript\nimport { useKeyboardKey } from 'react-keyboard-key';\n\nconst ExampleComponent: FC\u003cProps\u003e = () =\u003e {\n  const { keyInfo } = useKeyboardKey(onKeyDownCallback);\n\n  const onKeyDownCallback = (e: KeyboardEvent) =\u003e {\n    e.preventDefault\n  };\n\n  return (\n    \u003cdiv\u003e\n      {keyInfo.code}\n    \u003c/div\u003e\n  );\n};\n```\n\n## Project\n* [whatdidipress.com](https://whatdidipress.com/)\n* [Github project whatdidipress.com](https://github.com/patrikmasiar/what-did-i-press/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrikmasiar%2Freact-keyboard-key","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrikmasiar%2Freact-keyboard-key","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrikmasiar%2Freact-keyboard-key/lists"}