{"id":15696030,"url":"https://github.com/dbish6/react-user-input-detection","last_synced_at":"2026-05-07T06:37:48.110Z","repository":{"id":229206530,"uuid":"775797750","full_name":"dBish6/react-user-input-detection","owner":"dBish6","description":"A lightweight React hook dependency to effortlessly detect keyboard or mouse usage.","archived":false,"fork":false,"pushed_at":"2024-03-25T23:27:20.000Z","size":133,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T20:50:27.051Z","etag":null,"topics":["accessibility","dependency","detect","detection","hook","javascript","keyboard","mouse","npm","npm-package","react","react-hook","reactjs","typescript","user-input"],"latest_commit_sha":null,"homepage":"","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/dBish6.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.txt","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":"2024-03-22T04:00:35.000Z","updated_at":"2024-03-31T20:08:32.000Z","dependencies_parsed_at":"2024-03-22T19:29:06.194Z","dependency_job_id":"bd1bd74a-09ee-434c-8bef-b3ddf32ff30d","html_url":"https://github.com/dBish6/react-user-input-detection","commit_stats":null,"previous_names":["dbish6/react-is-keyboard-user"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dBish6%2Freact-user-input-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dBish6%2Freact-user-input-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dBish6%2Freact-user-input-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dBish6%2Freact-user-input-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dBish6","download_url":"https://codeload.github.com/dBish6/react-user-input-detection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246321892,"owners_count":20758710,"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":["accessibility","dependency","detect","detection","hook","javascript","keyboard","mouse","npm","npm-package","react","react-hook","reactjs","typescript","user-input"],"created_at":"2024-10-03T19:06:42.205Z","updated_at":"2026-05-07T06:37:48.082Z","avatar_url":"https://github.com/dBish6.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/dBish"],"categories":[],"sub_categories":[],"readme":"# react-user-input-detection\nA lightweight React hook for detecting the user's input method within a web application. This package provides a simple way to track whether a user is interacting via a keyboard or mouse, enhancing accessibility and the user experience of your application. The package also includes a context provider necessary for the hook's functionality. Regardless of whether the user begins with a keyboard and later transitions to a mouse, the hook dynamically detects these changes, recognizing the user's input method as mouse-based. This monitoring ensures accurate tracking of user interaction.\n\n## Installation\n```\n$ npm i react-user-input-detection\n```\n\n## Explanation\nTo utilize the hook, you must set up the context provider. The hook provides `isKeyboardUser` and `isKeyboardUserRef`, so you have the option to choose the state version or the ref version. When using the useState version, you must tell the provider to be stateful by providing the `state prop` to the IsKeyboardUserProvider. Use the useState version when re-rendering or DOM manipulation is necessary for your particular use case and anything other than that use the useRef version.\n\n### Provider\n```\n...\nimport { IsKeyboardUserProvider } from \"react-user-input-detection\";\n\nReactDOM.createRoot(document.getElementById(\"root\")).render(\n  \u003cIsKeyboardUserProvider\u003e // Uses the useRef version.\n    \u003cApp /\u003e\n  \u003c/IsKeyboardUserProvider\u003e\n);\n```\n```\n...\nimport { IsKeyboardUserProvider } from \"react-user-input-detection\";\n\nReactDOM.createRoot(document.getElementById(\"root\")).render(\n  \u003cIsKeyboardUserProvider state\u003e // Uses the useState version.\n    \u003cApp /\u003e\n  \u003c/IsKeyboardUserProvider\u003e\n);\n```\n\n### Hook\n```\nimport { useIsKeyboardUser } from \"react-user-input-detection\";\n\nfunction App() {\n  const { isKeyboardUserRef } = useIsKeyboardUser();\n\n  return (\n    \u003cbutton\n      onClick={() =\u003e\n        isKeyboardUserRef.current ? console.log(\"keyboard\") : console.log(\"mouse\") // useRef version use case.\n      }\n    \u003e\n      Keyboard detection!\n    \u003c/button\u003e\n  );\n}\n\nexport default App;\n```\n```\nimport { useIsKeyboardUser } from \"react-user-input-detection\";\n\nfunction App() {\n  const { isKeyboardUser } = useIsKeyboardUser();\n\n  return \u003cp\u003e{isKeyboardUser ? \"keyboard\" : \"mouse\"}\u003c/p\u003e; // useState version use case.\n}\n\nexport default App;\n```\n\n## Contributing\nContributions are welcome! Keep in mind I'd like to keep the package bundle size as small as possible.\n\n### To Get Started\n- Fork this repository.\n- Create a new branch.\n- install the dependencies with `npm install`.\n- Do a `npm run test` to see if you're all set.\n- For the dev environment, `npm run dev` and there you go!\n\n```\n$ npm install\n$ npm run test\n$ npm run dev\n```\n\n## License\nThis project is licensed under the [MIT](https://github.com/dBish6/react-user-input-detection/blob/master/LICENSE) License.\n\n## Support Me\nIf you find this package helpful consider buying me a coffee, your support helps me stay motivated!\n\n\u003ca href=\"https://www.buymeacoffee.com/dBish\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbish6%2Freact-user-input-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbish6%2Freact-user-input-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbish6%2Freact-user-input-detection/lists"}