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).
Install-Package KeystrokeAPI
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.
class Program
{
static void Main(string[] args)
{
using (var api = new KeystrokeAPI())
{
api.CreateKeyboardHook((character) => { Console.Write(character); });
Application.Run();
}
}
}