DeftSharp.Windows.Input 0.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DeftSharp.Windows.Input --version 0.3.0                
NuGet\Install-Package DeftSharp.Windows.Input -Version 0.3.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DeftSharp.Windows.Input" Version="0.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DeftSharp.Windows.Input --version 0.3.0                
#r "nuget: DeftSharp.Windows.Input, 0.3.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DeftSharp.Windows.Input as a Cake Addin
#addin nuget:?package=DeftSharp.Windows.Input&version=0.3.0

// Install DeftSharp.Windows.Input as a Cake Tool
#tool nuget:?package=DeftSharp.Windows.Input&version=0.3.0                

DeftSharp.Windows.Input

A lightweight library designed to handle and manage keyboard and mouse button events in Windows UI applications (WPF, MAUI, Avalonia). Using P/Invoke methods, this library provides an easy-to-use interface for event handling.

0.3 Release available! (10.03.2024)

What's new:

  • Keyboard Binder - a class for rebinding buttons
  • Small improvements (new methods)
  • Fixed bugs

You can see all the changes in the release changelog of our GitHub repository!

How to use

Subscription to left mouse click:


var mouseListener = new MouseListener();
            
mouseListener.Subscribe(MouseEvent.LeftButtonDown, () =>
{
    // This code will be triggered after each left mouse button click
});

One-time subscription for pressing a button on the keyboard:


var keyboardListener = new KeyboardListener();

keyboardListener.SubscribeOnce(Key.A, key =>
{
    // This code will only work once, after pressing button 'A'
});

You can customize each subscription to suit your needs:

Key[] keys = { Key.W, Key.A, Key.S, Key.D };
            
keyboardListener.Subscribe(keys, key =>
{
    // WASD clicks
}, 
 TimeSpan.FromSeconds(1), // Interval of click event
 KeyboardEvent.KeyUp); // Keyboard event type

Furthermore, you can take advantage of specialized classes for different usage scenarios. For example, for the NumPad:

var numpadListener = new NumpadListener(keyboardListener);
            
// 0-9 numpad buttons
numpadListener.Subscribe(number =>
{
    // Your code here
});

Contributing

We welcome any contributions to the development of this project. Whether you want to report a bug, suggest a new feature, or contribute code improvements, your input is highly valued. Please feel free to submit issues or pull requests through GitHub. Let's make this library even better together!

Feedback

If you have any ideas or suggestions. You can use this e-mail deftsharp@gmail.com for feedback.

Product Compatible and additional computed target framework versions.
.NET net7.0-windows7.0 is compatible.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.10.0 277 8/30/2024
0.9.0 251 4/16/2024
0.8.2 129 4/10/2024
0.8.1 126 4/7/2024
0.8.0 119 4/7/2024
0.7.1 140 4/1/2024
0.7.0 132 3/28/2024
0.6.0 142 3/24/2024
0.5.0 141 3/21/2024
0.4.0 123 3/18/2024
0.3.0 152 3/10/2024
0.2.0 149 3/6/2024
0.1.0 158 3/4/2024

What's new:

- Keyboard Binder - a class for rebinding buttons
- Small improvements (new methods)
- Fixed bugs