DeftSharp.Windows.Input
0.4.0
See the version list below for details.
dotnet add package DeftSharp.Windows.Input --version 0.4.0
NuGet\Install-Package DeftSharp.Windows.Input -Version 0.4.0
<PackageReference Include="DeftSharp.Windows.Input" Version="0.4.0" />
paket add DeftSharp.Windows.Input --version 0.4.0
#r "nuget: DeftSharp.Windows.Input, 0.4.0"
// Install DeftSharp.Windows.Input as a Cake Addin #addin nuget:?package=DeftSharp.Windows.Input&version=0.4.0 // Install DeftSharp.Windows.Input as a Cake Tool #tool nuget:?package=DeftSharp.Windows.Input&version=0.4.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.4 Release available! (19.03.2024)
What's new:
KeyboardListener:
- Sequence subscriptions
- Combination subscriptions
- Small changes of use
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0-windows7.0 is compatible. net8.0-windows was computed. |
-
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.
What's new:
KeyboardListener:
- Sequence subscriptions
- Combination subscriptions
- Small changes of use