VDT.Core.Blazor.GlobalEventHandler
5.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package VDT.Core.Blazor.GlobalEventHandler --version 5.0.0
NuGet\Install-Package VDT.Core.Blazor.GlobalEventHandler -Version 5.0.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="VDT.Core.Blazor.GlobalEventHandler" Version="5.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VDT.Core.Blazor.GlobalEventHandler" Version="5.0.0" />
<PackageReference Include="VDT.Core.Blazor.GlobalEventHandler" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VDT.Core.Blazor.GlobalEventHandler --version 5.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: VDT.Core.Blazor.GlobalEventHandler, 5.0.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.
#:package VDT.Core.Blazor.GlobalEventHandler@5.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VDT.Core.Blazor.GlobalEventHandler&version=5.0.0
#tool nuget:?package=VDT.Core.Blazor.GlobalEventHandler&version=5.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
VDT.Core.Blazor.GlobalEventHandler
Blazor component that allows you to handle global window level events in your application.
Features
- Window-level events that don't require focus on any element:
- Keyboard events
- Mouse events
- Touch events
- General events
Usage
To register event handlers, simply include the GlobalEventHandler component on your page and register your event handler with the event in the component that you want to handle. The available events are:
OnKeyDownwhich provides an optionalKeyboardEventArgsparameterOnKeyUpwhich provides an optionalKeyboardEventArgsparameterOnClickwhich provides an optionalMouseEventArgsparameterOnContextMenuwhich provides an optionalMouseEventArgsparameterOnDoubleClickwhich provides an optionalMouseEventArgsparameterOnMouseDownwhich provides an optionalMouseEventArgsparameterOnMouseUpwhich provides an optionalMouseEventArgsparameterOnMouseMovewhich provides an optionalMouseEventArgsparameterOnTouchStartwhich provides an optionalTouchEventargsparameterOnTouchEndwhich provides an optionalTouchEventargsparameterOnTouchCancelwhich provides an optionalTouchEventargsparameterOnTouchMovewhich provides an optionalTouchEventargsparameterOnResizewhich provides an optionalResizeEventArgsparameterOnScrollwhich provides an optionalScrollEventArgsparameterOnOfflinewhich provides an optionalWindowEventArgsparameterOnOnlinewhich provides an optionalWindowEventArgsparameter
Example
<GlobalEventHandler OnKeyDown="@OnWindowKeyDown" OnResize="@OnWindowResize" OnClick="@OnWindowClick" />
@if (keyDownEventArgs != null) {
<h2>Last key down event</h2>
<ul>
<li>Alt key: @keyDownEventArgs.AltKey</li>
<li>Code: @keyDownEventArgs.Code</li>
<li>Ctrl key: @keyDownEventArgs.CtrlKey</li>
<li>Key: @keyDownEventArgs.Key</li>
<li>Location: @keyDownEventArgs.Location</li>
<li>Meta key: @keyDownEventArgs.MetaKey</li>
<li>Repeat: @keyDownEventArgs.Repeat</li>
<li>Shift key: @keyDownEventArgs.ShiftKey</li>
<li>Type: @keyDownEventArgs.Type</li>
</ul>
}
@if (resizeEventArgs != null) {
<h2>Last resize event</h2>
<ul>
<li>Width: @resizeEventArgs.Width</li>
<li>Height: @resizeEventArgs.Height</li>
</ul>
}
@if (clicked) {
<h2>Clicked</h2>
}
@code {
private KeyboardEventArgs? keyDownEventArgs;
private ResizeEventArgs? resizeEventArgs;
private bool clicked = false;
// Handlers can be asynchronous ...
public async Task OnWindowKeyDown(KeyboardEventArgs args) {
keyDownEventArgs = args;
await Task.CompletedTask;
}
// ... Or synchronous
public void OnWindowResize(ResizeEventArgs args) {
resizeEventArgs = args;
}
// EventArgs are optional
public void OnWindowClick() {
clicked = true;
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.0)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.0)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on VDT.Core.Blazor.GlobalEventHandler:
| Package | Downloads |
|---|---|
|
VDT.Core.Blazor.DragAndDropList
Blazor component that allows users to reorder items in a list by dragging and dropping |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.0.1 | 120 | 1/31/2026 |
| 5.0.0 | 175 | 1/16/2026 |
| 4.0.0 | 319 | 1/11/2025 |
| 3.2.0 | 1,042 | 6/14/2024 |
| 3.1.0 | 216 | 6/1/2024 |
| 3.0.0 | 259 | 3/19/2024 |
| 2.2.0 | 357 | 8/17/2023 |
| 2.1.1 | 495 | 2/27/2023 |
| 2.1.0 | 384 | 2/23/2023 |
| 2.0.0 | 391 | 2/13/2023 |
| 1.2.0 | 419 | 2/12/2023 |
| 1.1.4 | 403 | 2/11/2023 |
| 1.1.3 | 407 | 2/3/2023 |
| 1.1.2 | 3,358 | 1/15/2022 |
| 1.1.1 | 443 | 1/15/2022 |
| 1.1.0 | 1,416 | 11/20/2021 |
| 1.0.0 | 501 | 11/9/2021 |
- Added explicit .net 10.0 support