Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

michel-pi/InputManager.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InputManager.Net

Nuget Nuget Open issues Closed issues MIT License

Net Framework 4.7 Net Framework 4.8

This library provides an easy to use interface for the native GetAsyncKeyState, GetKeyState and GetKeyboardState API and aswell synthesizes keyboard and mouse input.

To provide better compatibility to other implementations using VirtualKeyCodes i decided to not implement the enum myself and instead use the Windows Forms implementation which is a complete enum representing the native VK_ constants.

You can freely convert between Windows Forms Keys and WPF Key enum values.

NuGet

Install-Package AsyncKeyState.Net

This library is also available in the Github Package Registry.

Features

  • Get the current KeyStates of any virtual key using the AsyncInput class
  • Get and update all KeyStates at once using the KeyboardState class
  • Automatically thread safe KeyboardState using a thread static cache
  • Convert between WPF Key and Windows Forms Keys enum
  • Documented and tested class library

Examples

Using the AsyncInput class:

// returns a flags enum representing the state of the control key
AsyncInput.GetKeyState(Keys.Control);

// returns true if the ctrl key is currently pressed
AsyncInput.IsPressed(Keys.Control);

// and much more

Using the KeyboardState class: (Which also includes mouse states ;))

var keyboard = new KeyboardState();

for (int i = KeyboardState.MinKeyValue; i < KeyboardState.MaxKeyValue; i++)
{
    Console.WriteLine(keyboard.IsPressed((Keys)i));
}

Console.ReadLine();

You can get a thread static instance of KeyboardState by using:

var keyboard = KeyboardState.GetThreadStatic();

The thread static instance is automatically thread safe by design.

Contribute

The project file was generated using Visual Studio 2019.

Clone or download the repository and update/install the required NuGet packages.

You can help by reporting issues, adding new features, fixing bugs and by providing a better documentation.

Donate

Do you like this project and want to help me to keep working on it?

Then maybe consider to donate any amount you like.

Donate via PayPal

BTC     bc1qp6zc73vy8pmr6lfe4cxa6eqzvkuer9hrjwpzza

License

About

Provides access to GetAsyncKeyState and GetKeyboardState by implementing a complete managed wrapper.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published