{"id":28444208,"url":"https://github.com/bence-toth/react-hook-mouse","last_synced_at":"2025-06-29T17:32:37.223Z","repository":{"id":34174016,"uuid":"171059522","full_name":"bence-toth/react-hook-mouse","owner":"bence-toth","description":"A React hook to access mouse position, movement and button states","archived":false,"fork":false,"pushed_at":"2023-03-04T03:09:31.000Z","size":200,"stargazers_count":0,"open_issues_count":7,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-06T09:08:16.842Z","etag":null,"topics":["mouse","mouse-button","mouse-events","mouse-tracking","react","react-hooks"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bence-toth.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}},"created_at":"2019-02-16T22:41:12.000Z","updated_at":"2022-08-01T19:38:19.000Z","dependencies_parsed_at":"2023-01-15T05:04:57.153Z","dependency_job_id":null,"html_url":"https://github.com/bence-toth/react-hook-mouse","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/bence-toth/react-hook-mouse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bence-toth%2Freact-hook-mouse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bence-toth%2Freact-hook-mouse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bence-toth%2Freact-hook-mouse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bence-toth%2Freact-hook-mouse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bence-toth","download_url":"https://codeload.github.com/bence-toth/react-hook-mouse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bence-toth%2Freact-hook-mouse/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262637465,"owners_count":23341145,"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":["mouse","mouse-button","mouse-events","mouse-tracking","react","react-hooks"],"created_at":"2025-06-06T09:08:10.296Z","updated_at":"2025-06-29T17:32:37.214Z","avatar_url":"https://github.com/bence-toth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-hook-mouse :mouse:\n\nA React hook to access data from mouse events.\n\n## Installation\n\nUsing `npm`:\n\n```sh\nnpm install --save react-hook-mouse\n```\n\nUsing `yarn`:\n\n```sh\nyarn add react-hook-mouse\n```\n\n## Usage\n\n```jsx\nimport React from 'react'\nimport useMouse from 'react-hook-mouse'\n\nconst displayCoordinates = ({x, y}) =\u003e `${x} : ${y}`\n\nconst displayFlag = flag =\u003e flag ? 'Yes' : 'No'\n\nconst ComponentWithMouse = () =\u003e {\n  const mouse = useMouse()\n\n  return (\n    \u003cul\u003e\n      \u003cli\u003e\n        Mouse position in viewport:\n        {displayCoordinates(mouse.position.client)}\n      \u003c/li\u003e\n      \u003cli\u003e\n        Mouse position on page:\n        {displayCoordinates(mouse.position.page)}\n      \u003c/li\u003e\n      \u003cli\u003e\n        Mouse position on screen:\n        {displayCoordinates(mouse.position.screen)}\n      \u003c/li\u003e\n      \u003cli\u003e\n        Mouse movement:\n        {displayCoordinates(mouse.movement)}\n      \u003c/li\u003e\n      \u003cli\u003e\n        Left button was pressed:\n        {displayFlag(mouse.buttons.left)}\n      \u003c/li\u003e\n      \u003cli\u003e\n        Right button was pressed:\n        {displayFlag(mouse.buttons.right)}\n      \u003c/li\u003e\n      \u003cli\u003e\n        Middle button was pressed:\n        {displayFlag(mouse.buttons.middle)}\n      \u003c/li\u003e\n      \u003cli\u003e\n        Alt key was pressed:\n        {displayFlag(mouse.keyboard.alt)}\n      \u003c/li\u003e\n      \u003cli\u003e\n        Ctrl key was pressed:\n        {displayFlag(mouse.keyboard.ctrl)}\n      \u003c/li\u003e\n      \u003cli\u003e\n        Meta key was pressed:\n        {displayFlag(mouse.keyboard.meta)}\n      \u003c/li\u003e\n      \u003cli\u003e\n        Shift key was pressed:\n        {displayFlag(mouse.keyboard.shift)}\n      \u003c/li\u003e\n    \u003c/ul\u003e\n  )\n}\n```\n\n## Caveats\n\nData in `mouse.keyboard` is always read from a `MouseEvent` and therefore it will only get updated on mouse events, not when the keys are actually pressed on the keyboard.\n\n## Contributions\n\nContributions are welcome. File bug reports, create pull requests, feel free to reach out at tothab@gmail.com.\n\n## Licence\n\nLGPL-3.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbence-toth%2Freact-hook-mouse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbence-toth%2Freact-hook-mouse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbence-toth%2Freact-hook-mouse/lists"}