SkillAgentSearch skills...

TinyHotKey

Windows HotKey handler without dependency on keyboard hooks, Windows Forms, WPF.

Install / Use

/learn @steamcore/TinyHotKey
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

TinyHotKey

NuGet Build

TinyHotKey is a Windows HotKey handler with no dependency on Windows Forms or WPF that only listen to specified key combinations. It uses RegisterHotKey from the Win32 API directly on a dedicated thread using a hidden window, avoiding global hooks.

Simple example

using var tinyHotKey = new TinyHotKeyInstance();

using var registration = tinyHotKey.RegisterHotKey(Modifier.Control | Modifier.Alt, Key.D, () =>
{
	Console.WriteLine("Ctrl+Alt+D detected");

	return Task.CompletedTask;
});

Example using dependency injection

// Add TinyHotKey to your DI container with logging support
services.AddTinyHotKey();

// In a service with a dependency on ITinyHotKey
using var registration = tinyHotKey.RegisterHotKey(Modifier.Control | Modifier.Alt, Key.D, () =>
{
    Console.WriteLine("Ctrl+Alt+D detected");

    return Task.CompletedTask;
});

Why TinyHotKey?

Unlike other projects TinyHotKey has no dependency on Windows Form or WPF and does not use global hooks, which makes it possible to avoid keylogger-like behavior and also support trimming and AOT.

It is possible to use TinyHotKey in alternate UI frameworks such as Avalonia or even in console applications.

How it works

The Windows hotkey mechanism works by detecting keyboard combinations and posting messages to a Window. TinyHotKey creates a hidden Window on a dedicated thread using Win32 calls, handling all hotkey interactions and invoking callbacks on a new task off the "UI" thread. This approach allows it to work in any kind of application running on Windows without relying on Windows Forms or WPF which are not trimming or AOT compatible.

View on GitHub
GitHub Stars12
CategoryDevelopment
Updated1d ago
Forks1

Languages

C#

Security Score

90/100

Audited on Apr 4, 2026

No findings