Skip to content

Latest commit

 

History

History
38 lines (31 loc) · 1.04 KB

README.md

File metadata and controls

38 lines (31 loc) · 1.04 KB

KeystrokeAPI

A simple Keystroke API written in C# that works for any version of Windows. It abstracts the access to the win32.dll and the handling of low level hooks (only keyboard for now).

Instalation

Install-Package KeystrokeAPI

How to use

1 - Call the CreateKeyboardHook() method passing your callback like this:

api.CreateKeyboardHook((character) => { Console.Write(character); });

2 - Implement your own "Windows Message Loop" OR call this:

Application.Run();

NOTE: This call starts the windows message loop for you, but you will need to reference the System.Windows.Forms.dll in your project. Click here to know why.

Code Example (using a Console Application)

class Program
{
    static void Main(string[] args)
    {
        using (var api = new KeystrokeAPI())
        {
            api.CreateKeyboardHook((character) => { Console.Write(character); });
            Application.Run();
        }
    }
}