{"id":23078234,"url":"https://github.com/basementuniverse/input-manager","last_synced_at":"2025-08-15T19:33:17.646Z","repository":{"id":65408452,"uuid":"583070983","full_name":"basementuniverse/input-manager","owner":"basementuniverse","description":"A component for handling input events and managing input device state","archived":false,"fork":false,"pushed_at":"2024-11-04T23:39:46.000Z","size":261,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-02T14:05:02.686Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/basementuniverse.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":"2022-12-28T17:16:01.000Z","updated_at":"2024-11-04T23:39:50.000Z","dependencies_parsed_at":"2024-05-30T13:26:04.446Z","dependency_job_id":null,"html_url":"https://github.com/basementuniverse/input-manager","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"e1918f5aac7bb8cc08e0fd8cab9fdbdc6ba4cfa3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basementuniverse%2Finput-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basementuniverse%2Finput-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basementuniverse%2Finput-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basementuniverse%2Finput-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basementuniverse","download_url":"https://codeload.github.com/basementuniverse/input-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229504608,"owners_count":18083397,"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":[],"created_at":"2024-12-16T10:52:35.728Z","updated_at":"2025-08-15T19:33:17.637Z","avatar_url":"https://github.com/basementuniverse.png","language":"TypeScript","readme":"# Game Component: Input Manager\n\nA component for handling input events and managing input device state.\n\n## Installation\n\n```bash\nnpm install @basementuniverse/input-manager\n```\n\n## How to use\n\nInitialise the input manager before use:\n\n```ts\nimport InputManager from '@basementuniverse/input-manager';\n\nInputManager.initialise();\n```\n\nUpdate the input manager state:\n\n```ts\nclass Game {\n  // ...\n\n  public update(context: CanvasRenderingContext2D) {\n    InputManager.update();\n  }\n}\n```\n\nCheck the state of input devices:\n\n```ts\n// Check if any key is currently down\nInputManager.keyDown();\n\n// Check if a specific key is currently down\nInputManager.keyDown(code?);\n\n// Check if a key was pressed\nInputManager.keyPressed(code?);\n\n// Check if a key was released\nInputManager.keyReleased(code?);\n\n// Check if the main mouse button is currently down\nInputManager.mouseDown(button?);\n\n// Check if the main mouse button was pressed\nInputManager.mousePressed(button?);\n\n// Check if the main mouse button was released\nInputManager.mouseReleased(button?);\n\n// Check if the mouse wheel was scrolled up\nInputManager.mouseWheelUp();\n\n// Check if the mouse wheel was scrolled down\nInputManager.mouseWheelDown();\n\n// Get the current mouse position in screen-space\nconst position = InputManager.mousePosition;\n\n// Get the currently hovered HTML element (or null if there isn't one)\nconst hoveredElement = InputManager.hoveredElement;\n```\n\nSee [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code) for a reference of key codes.\n\n## Options\n\n```ts\nconst options = { ... };\nInputManager.initialise(options);\n```\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `element` | `Window \\| HTMLElement` | `window` | The element to listen for mouse input events on |\n| `mouse` | `boolean` | `true` | Enable mouse input |\n| `mouseWheel` | `boolean` | `true` | Enable mouse wheel input |\n| `keyboard` | `boolean` | `true` | Enable keyboard input |\n| `preventContextMenu` | `boolean` | `false` | Try to prevent the context menu from appearing on right-click |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasementuniverse%2Finput-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasementuniverse%2Finput-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasementuniverse%2Finput-manager/lists"}