Skip to content

A simple and easy-to-use .NET managed wrapper for Low Level Keyboard hooking.

License

Notifications You must be signed in to change notification settings

goupviet/Open.WinKeyboardHook

 
 

Repository files navigation

Build status NuGet version

Open.WinKeyboardHook

A simple and easy-to-use .NET managed wrapper for Low Level Keyboard hooking.

Goals

The main goal is to abstract away the complexities inherit to intercept and translate global keystrokes (KeyDown / KeyUp / KeyPress) in the system.

Usage

public partial class TestForm : Form
{
    private readonly IKeyboardInterceptor _interceptor;

    public TestForm()
    {
        InitializeComponent();

        // Everytime a key is press we want to display it in a TextBox
        _interceptor = new KeyboardInterceptor();
        _interceptor.KeyPress += (sender, args) => txt.Text += args.KeyChar;
    }

    // Start and Stop capturing keystroks
    private void BtnClick(object sender, EventArgs e)
    {
        if(!_capturing)
        {
            _interceptor.StartCapturing();
            btn.Text = "Stop";
            btn.BackColor = Color.Red;
        }
        else
        {
            _interceptor.StopCapturing();
            btn.Text = "Start";
            btn.BackColor = Color.Lime;
        }
        _capturing = !_capturing;
    }
}

Real world example

Open.WinKeyboardHook is been used as the key component in KeyPadawan project, a useful tool for presentation and screencasts that allow to display the shortcuts that a presenter uses.

Development

Open.WinKeyboardHook is been developed by Lucas Ontivero (@lontivero). You are welcome to contribute code. You can send code both as a patch or a GitHub pull request.

About

A simple and easy-to-use .NET managed wrapper for Low Level Keyboard hooking.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%