EzeIO.Keylogger 1.1.0

dotnet add package EzeIO.Keylogger --version 1.1.0
                    
NuGet\Install-Package EzeIO.Keylogger -Version 1.1.0
                    
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="EzeIO.Keylogger" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EzeIO.Keylogger" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="EzeIO.Keylogger" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EzeIO.Keylogger --version 1.1.0
                    
#r "nuget: EzeIO.Keylogger, 1.1.0"
                    
#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.
#:package EzeIO.Keylogger@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EzeIO.Keylogger&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=EzeIO.Keylogger&version=1.1.0
                    
Install as a Cake Tool

Keyboard

NuGet build

A library that uses the Windows low-level keyboard hook (WH_KEYBOARD_LL) to raise an event when a key is pressed, with COM support.

Targets .NET Framework 4.6.2+ and .NET 8 (net8.0-windows).

Usage

Install the package, then use the namespace:

dotnet add package EzeIO.Keylogger
using Eze.IO.Workspace;

Subscribe to key presses

static void Main(string[] args)
{
    DetectKey.OnKeyPressed += OnKeyPress_Handled;
}

static void OnKeyPress_Handled(LoggedKeys keys)
{
    VirtualKeys k = keys.Key;
    if (k == VirtualKeys.Enter)
    {
        // User pressed the 'Enter' key
    }
}

Adding the first handler installs the hook; removing the last handler (-=) uninstalls it. DetectKey.IsDetecting reports whether the hook is currently installed.

LoggedKeys exposes the pressed key as a VirtualKeys value (Key) and its name (KeyName).

COM

DetectKeyFactory (ProgId Eze.IO.Workspace.DetectKeyFactory) exposes the same event to COM clients such as VBScript or VBA, once the .NET Framework build is registered with regasm /codebase Keyboard.dll. Set Detect to true to start raising OnKeyPressed.

Building

dotnet build Keylogger.sln
dotnet pack src/Keyboard.csproj -c Release -o artifacts

The hook is a Windows API and runs on Windows only.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.2

    • No dependencies.
  • 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.1.0 85 10/22/2026