{"id":13730231,"url":"https://github.com/elringus/unity-raw-input","last_synced_at":"2025-04-10T03:57:17.450Z","repository":{"id":61348271,"uuid":"129297673","full_name":"elringus/unity-raw-input","owner":"elringus","description":"Windows Raw Input wrapper for Unity game engine","archived":false,"fork":false,"pushed_at":"2024-01-19T17:17:16.000Z","size":97,"stargazers_count":223,"open_issues_count":2,"forks_count":15,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-10T03:57:12.847Z","etag":null,"topics":["background","event-driven","input","native","unity3d","unity3d-plugin"],"latest_commit_sha":null,"homepage":"https://elringus.me/using-windows-rawinput-api-in-unity/","language":"C#","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/elringus.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"elringus"}},"created_at":"2018-04-12T18:52:50.000Z","updated_at":"2025-04-05T09:52:52.000Z","dependencies_parsed_at":"2024-08-03T02:23:10.229Z","dependency_job_id":"d0254a47-d14f-4bc6-9c24-1aa63606d9be","html_url":"https://github.com/elringus/unity-raw-input","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elringus%2Funity-raw-input","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elringus%2Funity-raw-input/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elringus%2Funity-raw-input/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elringus%2Funity-raw-input/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elringus","download_url":"https://codeload.github.com/elringus/unity-raw-input/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154997,"owners_count":21056542,"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":["background","event-driven","input","native","unity3d","unity3d-plugin"],"created_at":"2024-08-03T02:01:11.856Z","updated_at":"2025-04-10T03:57:17.415Z","avatar_url":"https://github.com/elringus.png","language":"C#","funding_links":["https://github.com/sponsors/elringus"],"categories":["C#"],"sub_categories":[],"readme":"## Description\n\nWrapper over [Windows Raw Input API](https://msdn.microsoft.com/en-us/library/windows/desktop/ms645536(v=vs.85).aspx) to hook for the native input events. Allows receiving input events even when the Unity application is in background (not in focus).\n\nWill only work on Windows platform.\n\nOnly keyboard and mouse input is detected.\n\n## Installation\n\nDownload and import the package: [UnityRawInput.unitypackage](https://github.com/elringus/unity-raw-input/raw/main/UnityRawInput.unitypackage).\n\n## Usage\n\nEnable `Run In Background` in project's player settings; if not enabled, expect severe mouse slowdown when the application is not in focus https://github.com/elringus/unity-raw-input/issues/19#issuecomment-1227462101.\n\n![](https://i.gyazo.com/9737f66dafa9c705601521b82f40fc5a.png)\n\nInitialize the service to start processing input messages:\n\n```csharp\nRawInput.Start();\n```\n\nOptionally, configure whether input messages should be handled when the application is not in focus and whether handled messages should be intercepted (both disabled by default):\n\n```csharp\nRawInput.WorkInBackground = true;\nRawInput.InterceptMessages = false;\n```\n\nAdd listeners to handle input events:\n\n```csharp\nRawInput.OnKeyUp += HandleKeyUp;\nRawInput.OnKeyDown += HandleKeyDown;\n\nprivate void HandleKeyUp (RawKey key) { ... }\nprivate void HandleKeyDown (RawKey key) { ... }\n```\n\nCheck whether specific key is currently pressed:\n\n```csharp\nif (RawInput.IsKeyDown(key)) { ... }\n```\n\nStop the service:\n\n```csharp\nRawInput.Stop();\n```\n\nDon't forget to remove listeners when you no longer need them:\n\n```csharp\nprivate void OnDisable ()\n{\n    RawInput.OnKeyUp -= HandleKeyUp;\n    RawInput.OnKeyDown -= HandleKeyDown;\n}\n```\n\nFind usage example in the project: https://github.com/elringus/unity-raw-input/blob/main/Assets/Runtime/LogRawInput.cs.\n\nList of the raw keys with descriptions: https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felringus%2Funity-raw-input","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felringus%2Funity-raw-input","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felringus%2Funity-raw-input/lists"}