KeyboardHookLite 1.1.3

.NET 6.0
dotnet add package KeyboardHookLite --version 1.1.3
NuGet\Install-Package KeyboardHookLite -Version 1.1.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KeyboardHookLite" Version="1.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add KeyboardHookLite --version 1.1.3
#r "nuget: KeyboardHookLite, 1.1.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install KeyboardHookLite as a Cake Addin
#addin nuget:?package=KeyboardHookLite&version=1.1.3

// Install KeyboardHookLite as a Cake Tool
#tool nuget:?package=KeyboardHookLite&version=1.1.3

🎯 Features

  • Lightweight low-level global keyboard hook with minimal dependencies.
  • Designed to work with modern UI frameworks (WPF, MAUI, WinUI 3) out of the box - no fiddling with outdated namespaces and Key types.
  • Uses PInvoke signatures in order to avoid reliance on CsWin32 source generator.
  • Source code is commented and thoroughly explained to allow you to expand functionality.
  • Proper garbage disposal of unmanaged code to prevent memory leaks.
  • Usage guide below allows you to get up and running quickly.

⚡️ Usage Guide

Bring in the namespace

Console Application

WPF / WinUI 3 / Other

It is essentially the same as the code for the console application above. You can omit System.Windows.Threading.Dispatcher.Run(); as UI frameworks already have a message queue. You can initialize the keyboard hook wherever you choose, whether it be upon a click or when the screen is initialized. Please remember to dispose (kbh.Dispose();) when you no longer require the hook.

KeyboardHookEventArgs features

KeyboardHookEventArgs contains the property KeyPressType and InputEvent which is of type LowLevelKeyboardInputEvent. See below for what that entails. If you would like to add further functionality, you can do so by adding properties to KeyboardHookEventArgs.



Product Versions
.NET net6.0-windows net6.0-windows7.0 net7.0-windows net7.0-windows7.0
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • net6.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on KeyboardHookLite:

Repository Stars
Build .NET browser / native UI in declarative C#
Version Downloads Last updated
1.1.3 579 8/9/2022
1.1.2 263 8/9/2022
1.1.1 242 8/8/2022
1.1.0 247 8/8/2022
1.0.0 262 8/7/2022