GameInput.Net
1.2.2
dotnet add package GameInput.Net --version 1.2.2
NuGet\Install-Package GameInput.Net -Version 1.2.2
<PackageReference Include="GameInput.Net" Version="1.2.2" />
<PackageVersion Include="GameInput.Net" Version="1.2.2" />
<PackageReference Include="GameInput.Net" />
paket add GameInput.Net --version 1.2.2
#r "nuget: GameInput.Net, 1.2.2"
#:package GameInput.Net@1.2.2
#addin nuget:?package=GameInput.Net&version=1.2.2
#tool nuget:?package=GameInput.Net&version=1.2.2
About
GameInput.Net is a .NET wrapper around Microsoft's GameInput library, a modern input capture system introduced woth the Microsoft Game Development Kit.
Prerequisites
You must have Windows 10 or 11 with the GameInput library installed. It is recommended you distribute the GameInput Redistributable with your software to ensure the user has the most recent version. GameInput.Net will look for the re-distributable before the boxed version.
This is included in the Microsoft.GameInput package, though not automatically installed.
How to Use
Download the package in your favorite IDE such as Jetbrains Rider or Microsoft Visual Studio using the NuGet package manager. You may also install via commandline dotnet tools.
dotnet add package GameInputNet
Compatible with .NET 6.0+ you can instantiate a GameInput object and access all of the native GameInput through the managed wrapper.
using GameInputDotNet;
using GameInputDotNet.Interop.Enums;
using var _gameInput = GameInput.Create();
// Set focus allow capture of inputs regardless of program focus.
_gameInput.SetFocusPolicy(GameInputFocusPolicy.EnableBackgroundInput);
while (true)
{
// Slow down the loop so we don't get spammed.
Thread.Sleep(100);
GameInputReading? reading = null;
try
{
// Get the current frame's "Keyboard" inputs.
reading = _gameInput.GetCurrentReading(GameInputKind.Keyboard);
}
catch (GameInputException)
{
// Handle exceptions and unprepared reading from first frame.
continue;
}
if (reading is null) continue;
using (reading)
{
// Get the current state.
var state = reading.GetKeyboardState();
// Nothing pressed we can jump to the next loop.
if (state.Keys.Count == 0)
continue;
// Report the scan code of each key currently pressed.
Console.Write("Keys Pressed: ");
foreach (var key in state.Keys) Console.Write(key.ScanCode + " ");
Console.WriteLine();
// We can also use this to end our program when the user hits Escape.
if (state.Keys.Any(key => key.ScanCode == 1))
{
Console.WriteLine("Got ESCAPE key, ending program.");
break;
}
}
}
Documentation & Feedback
If you have issues or recommendations please submit a ticket through the GameInput.Net GitHub. The repo also contains additional documentation and examples.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
-
net8.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.2.2 | 131 | 12/30/2025 |
| 1.0.3 | 314 | 11/12/2025 |
| 0.1.0-ops-setupNuGet.1 | 66 | 11/9/2025 |