Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time
May 11, 2023 20:17
May 11, 2023 19:08
August 25, 2022 00:40
January 4, 2023 20:47
April 25, 2022 16:17
November 6, 2022 01:18


Wrapper over Windows Raw Input API to hook for the native input events. Allows receiving input events even when the Unity application is in background (not in focus).

Will only work on Windows platform.

Only keyboard and mouse input is detected.


Download and import the package: UnityRawInput.unitypackage.


Enable Run In Background in project's player settings; if not enabled, expect severe mouse slowdown when the application is not in focus #19 (comment).

Initialize the service to start processing input messages:


Optionally, 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):

RawInput.WorkInBackground = true;
RawInput.InterceptMessages = false;

Add listeners to handle input events:

RawInput.OnKeyUp += HandleKeyUp;
RawInput.OnKeyDown += HandleKeyDown;

private void HandleKeyUp (RawKey key) { ... }
private void HandleKeyDown (RawKey key) { ... }

Check whether specific key is currently pressed:

if (RawInput.IsKeyDown(key)) { ... }

Stop the service:


Don't forget to remove listeners when you no longer need them:

private void OnDisable ()
    RawInput.OnKeyUp -= HandleKeyUp;
    RawInput.OnKeyDown -= HandleKeyDown;

Find usage example in the project:

List of the raw keys with descriptions: