GlobalKeyboardCapture.Maui
1.0.1
Requires NuGet 6.0.0 or higher.
dotnet add package GlobalKeyboardCapture.Maui --version 1.0.1
NuGet\Install-Package GlobalKeyboardCapture.Maui -Version 1.0.1
<PackageReference Include="GlobalKeyboardCapture.Maui" Version="1.0.1" />
paket add GlobalKeyboardCapture.Maui --version 1.0.1
#r "nuget: GlobalKeyboardCapture.Maui, 1.0.1"
// Install GlobalKeyboardCapture.Maui as a Cake Addin #addin nuget:?package=GlobalKeyboardCapture.Maui&version=1.0.1 // Install GlobalKeyboardCapture.Maui as a Cake Tool #tool nuget:?package=GlobalKeyboardCapture.Maui&version=1.0.1
GlobalKeyboardCapture.Maui
A powerful .NET MAUI library for global keyboard capture with strong support for barcode scanners. Provides system-wide key interception, hotkeys management.
Demo application showing key capture, barcode scanning, and hotkeys functionality
Features
- 🔑 Global keyboard capture
- 📊 Advanced keyboard input processing
- 🏷️ Built-in barcode scanner support
- ⌨️ Customizable hotkeys system
- 📱 Cross-platform (Windows & Android)
- 🎛️ Highly configurable
- 🧩 Easy to integrate
- 🔧 Built for .NET MAUI
Common Use Cases
- Barcode scanner integration
- Global hotkeys and shortcuts
- System-wide keyboard monitoring
- Custom keyboard input handling
- Input automation
- Multi-mode keyboard capture
Installation
dotnet add package GlobalKeyboardCapture.Maui
Or via the NuGet Package Manager:
Install-Package GlobalKeyboardCapture.Maui
Quick Start
- Register the service in your
MauiProgram.cs
:
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseKeyboardHandling();
builder.Services.AddKeyboardHandling(options =>
{
// Barcode specific settings
options.BarcodeTimeout = 150;
options.MinBarcodeLength = 8;
});
return builder.Build();
}
- Basic usage example:
public partial class MainPage : ContentPage
{
private readonly IKeyHandlerService _keyHandlerService;
private readonly BarcodeHandler _barcodeHandler;
private readonly HotkeyHandler _hotkeyHandler;
public MainPage(
IKeyHandlerService keyHandlerService,
BarcodeHandler barcodeHandler,
HotkeyHandler hotkeyHandler)
{
InitializeComponent();
_keyHandlerService = keyHandlerService;
_barcodeHandler = barcodeHandler;
_hotkeyHandler = hotkeyHandler;
SetupHandlers();
}
private void SetupHandlers()
{
// Setup barcode handling
_barcodeHandler.BarcodeScanned += (sender, input) =>
{
MainThread.BeginInvokeOnMainThread(() =>
{
ProcessInput(input);
});
};
// Setup global hotkeys
_hotkeyHandler.RegisterHotkey("F2", () =>
{
EnableEditMode();
});
// Register handlers
_keyHandlerService.RegisterHandler(_barcodeHandler);
_keyHandlerService.RegisterHandler(_hotkeyHandler);
}
}
Advanced Usage
Custom Key Handler
Create your own key handler for specific needs:
public class CustomKeyHandler : IKeyHandler
{
public bool ShouldHandle(string key) => true;
public void HandleKey(string key)
{
// Your custom key handling logic
}
}
Global Hotkeys
// Single key hotkeys
_hotkeyHandler.RegisterHotkey("F2", EnableEditMode);
_hotkeyHandler.RegisterHotkey("ESC", CancelOperation);
// Modifier key combinations
_hotkeyHandler.RegisterHotkey("Shift+S", SaveAction);
_hotkeyHandler.RegisterHotkey("Ctrl+Alt+P", PrintAction);
_hotkeyHandler.RegisterHotkey("Ctrl+Alt+Shift+P", PrintAction);
//Special keys
_hotkeyHandler.RegisterHotkey("VolumeUp", VolumeControlAction); //Android Volume Up
_hotkeyHandler.RegisterHotkey("OEM173", VolumeControlAction); //OEM 173
Barcode Scanner Mode
_barcodeHandler.BarcodeScanned += (sender, input) =>
{
ProcessProduct(input);
};
Key Features
Global Key Capture
- Capture keyboard input regardless of focus
- Works with all UI controls
- System-wide key interception
Input Processing
- Configurable input timeout
- Input validation and filtering
- Custom processing rules
Platform Support
- Windows desktop applications
- Android mobile applications
- Consistent API across platforms
API Reference
Core Services
IKeyHandlerService
: Main service for global keyboard handlingBarcodeHandler
: Specialized handler for barcode input scenariosHotkeyHandler
: Global hotkeys management
Interfaces
IKeyHandler
: Base interface for custom handlersILifecycleHandler
: Application lifecycle management
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Anderson Fernandes do Nascimento
Support
If you encounter any issues or need help, please open an issue.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0-android34.0 is compatible. net8.0-windows10.0.19041 is compatible. net9.0-android35.0 is compatible. net9.0-windows10.0.19041 is compatible. |
-
net8.0-android34.0
- Microsoft.Maui.Controls (>= 8.0.83)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.83)
-
net8.0-windows10.0.19041
- Microsoft.Maui.Controls (>= 8.0.83)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.83)
-
net9.0-android35.0
- Microsoft.Maui.Controls (>= 9.0.0)
- Microsoft.Maui.Controls.Compatibility (>= 9.0.0)
-
net9.0-windows10.0.19041
- Microsoft.Maui.Controls (>= 9.0.0)
- Microsoft.Maui.Controls.Compatibility (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release of GlobalKeyboardCapture.Maui