DeftSharp.Windows.Input 0.2.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.2.0
NuGet\Install-Package DeftSharp.Windows.Input -Version 0.2.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.2.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.2.0
#r "nuget: DeftSharp.Windows.Input, 0.2.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.2.0

// Install DeftSharp.Windows.Input as a Cake Tool
#tool nuget:?package=DeftSharp.Windows.Input&version=0.2.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.2 Release available! (06.03.2024)

What's new:

  • Mouse Manipulator - a mouse control class.
  • Keyboard Manipulator - a keyboard control class.
  • Fixed minor 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.9.0 115 4/16/2024
0.8.2 86 4/10/2024
0.8.1 87 4/7/2024
0.8.0 86 4/7/2024
0.7.1 99 4/1/2024
0.7.0 86 3/28/2024
0.6.0 105 3/24/2024
0.5.0 106 3/21/2024
0.4.0 99 3/18/2024
0.3.0 114 3/10/2024
0.2.0 102 3/6/2024
0.1.0 97 3/4/2024

What's new:

- Mouse Manipulator - a mouse control class.
- Keyboard Manipulator - a keyboard control class.
- Fixed minor bugs