+
@ChildContent
\ No newline at end of file
diff --git a/Json_exe.Blazor.HotkeyManager/HotkeyManagerContainer.razor.cs b/Json_exe.Blazor.HotkeyManager/HotkeyManagerContainer.razor.cs
index 219475f..4c92303 100644
--- a/Json_exe.Blazor.HotkeyManager/HotkeyManagerContainer.razor.cs
+++ b/Json_exe.Blazor.HotkeyManager/HotkeyManagerContainer.razor.cs
@@ -11,6 +11,16 @@ public sealed partial class HotkeyManagerContainer : ComponentBase, IAsyncDispos
{
[Inject] private HotkeyManager HotkeyManager { get; set; } = null!;
+ ///
+ /// Additional classes you want to apply to the container wrapping your child content.
+ ///
+ [Parameter] public string Class { get; set; } = string.Empty;
+
+ ///
+ /// Additional styles you want to apply to the container wrapping your child content.
+ ///
+ [Parameter] public string Style { get; set; } = string.Empty;
+
///
/// The child content to be rendered.
///
diff --git a/Json_exe.Blazor.HotkeyManager/HotkeyManagerOptions.cs b/Json_exe.Blazor.HotkeyManager/HotkeyManagerOptions.cs
index 4c96b09..5056f52 100644
--- a/Json_exe.Blazor.HotkeyManager/HotkeyManagerOptions.cs
+++ b/Json_exe.Blazor.HotkeyManager/HotkeyManagerOptions.cs
@@ -16,7 +16,7 @@ public sealed record HotkeyManagerOptions
/// The hotkeys you want the HotkeyManager to listen for.
///
public IReadOnlyList
Hotkeys { get; init; } = [];
-};
+}
///
/// Defines a hotkey that the Manager should look for.
diff --git a/Json_exe.Blazor.HotkeyManager/Json_exe.Blazor.HotkeyManager.csproj b/Json_exe.Blazor.HotkeyManager/Json_exe.Blazor.HotkeyManager.csproj
index a4c62fd..cbba44f 100644
--- a/Json_exe.Blazor.HotkeyManager/Json_exe.Blazor.HotkeyManager.csproj
+++ b/Json_exe.Blazor.HotkeyManager/Json_exe.Blazor.HotkeyManager.csproj
@@ -1,6 +1,6 @@
- net9.0
+ net8.0;net9.0
enable
enable
true
@@ -22,8 +22,11 @@
-
-
+
+
+
+
+
diff --git a/Json_exe.Blazor.HotkeyManager/README.md b/Json_exe.Blazor.HotkeyManager/README.md
index 1013efb..6b9c252 100644
--- a/Json_exe.Blazor.HotkeyManager/README.md
+++ b/Json_exe.Blazor.HotkeyManager/README.md
@@ -1,19 +1,45 @@
# Blazor Hotkey Manager
-Blazor Hotkey Manager is a library for managing hotkeys in Blazor applications. It provides a simple and flexible way to handle keyboard shortcuts in your Blazor components.
+Blazor Hotkey Manager is a library for managing hotkeys in Blazor applications. It provides a simple and flexible way to
+handle keyboard shortcuts in your Blazor components.
+
+## Table of Contents
+
+
+* [Blazor Hotkey Manager](#blazor-hotkey-manager)
+ * [Table of Contents](#table-of-contents)
+ * [Release-Notes](#release-notes)
+ * [Installation](#installation)
+ * [Building Locally](#building-locally)
+ * [How to use?](#how-to-use)
+ * [Contributing](#contributing)
+ * [Technologies Used](#technologies-used)
+
+
+## Release-Notes
+
+For release notes please look here: https://github.com/Json-exe/Blazor.HotkeyManager/releases/latest
+
+---
## Installation
To install the NuGet package, run the following command in your NuGet Package Manager Console:
```sh
-Install-Package Blazor.HotkeyManager
+Install-Package Json_exe.Blazor.HotkeyManager
+```
+
+or
+
+```sh
+dotnet add package Json_exe.Blazor.HotkeyManager
```
Alternatively, you can add the package reference directly to your .csproj file:
```cs
-
+
```
## Building Locally
@@ -23,7 +49,7 @@ To build the package locally, follow these steps:
1. Clone the repository:
```sh
-git clone https://github.com/yourusername/Blazor.HotkeyManager.git
+git clone https://github.com/Json-exe/Blazor.HotkeyManager.git
```
2. Navigate to the project directory:
@@ -44,54 +70,70 @@ dotnet restore
dotnet build
```
+---
+
## How to use?
+
1. Register the HotkeyManager on your Service provider:
+
```csharp
builder.Services.AddHotkeyManager();
```
-2. To globally use the HotkeyManager in your program or on a whole page/layout, inject the HotkeyManager in your component:
+2. To globally use the HotkeyManager in your program or on a whole page/layout, inject the HotkeyManager in your
+ component:
+
```csharp
[Inject] private HotkeyManager HotkeyManager {get; init;}
```
-3. In the OnAfterRender (or any other lifecycle method you like, that supports JSInterop), Initialize the HotkeyManager with your options like this:
+3. In the OnAfterRender (or any other lifecycle method you like, that supports JSInterop), Initialize the HotkeyManager
+ with your options like this:
+
```csharp
- await HotkeyManager.Initialize(new HotkeyManagerOptions
- {
- Hotkeys =
- [
- new Hotkey
- {
- Key = "S",
- CtrlKey = true,
- PreventDefault = true
- },
- new Hotkey
- {
- Key = "F",
- CtrlKey = true,
- PreventDefault = true
- }
- ]
- });
+await HotkeyManager.Initialize(new HotkeyManagerOptions
+{
+ Hotkeys =
+ [
+ new Hotkey
+ {
+ Key = "S",
+ CtrlKey = true,
+ PreventDefault = true
+ },
+ new Hotkey
+ {
+ Key = "F",
+ CtrlKey = true,
+ PreventDefault = true
+ }
+ ]
+});
```
4. Register on the OnHotkeyPressed event of the HotkeyManager to recieve hotkey events:
+
```csharp
HotkeyManager.OnHotkeyPressed += OnHotkeyManagerOnHotkeyPressed;
```
-### Attention: Dont forget to Dispose the HotkeyManager and deregister afterwards when you are finished using it! Else it will lead to unexpected behaviour like your Hotkeys being triggered on another component.
+> Attention: Don't forget to Dispose the HotkeyManager and deregister afterwards when you are finished using it! Else it
+> will lead to unexpected behaviour like your Hotkeys being triggered on another component.
+
```csharp
HotkeyManager.OnHotkeyPressed -= OnHotkeyManagerOnHotkeyPressed;
await HotkeyManager.DisposeAsync();
```
+---
+
## Contributing
-I welcome contributions from the community! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request. Let's make Blazor Hotkey Manager better together!
+
+I welcome contributions from the community! If you have any ideas, suggestions, or bug reports, please open an issue or
+submit a pull request. Let's make Blazor Hotkey Manager better together!
## Technologies Used
+
- Blazor: A framework for building interactive web UIs with C#.
- .NET: A free, cross-platform, open-source developer platform for building many different types of applications.
- NuGet: A package manager for .NET.
diff --git a/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.js b/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.js
index be578fe..69ca6dd 100644
--- a/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.js
+++ b/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.js
@@ -34,7 +34,7 @@ function keyDownEvent(e) {
if (options.hotkeys.length <= 0) {
return;
}
- let hotkey = options.hotkeys.find(h => h.key.toLowerCase() === e.key && h.ctrlKey === e.ctrlKey && h.shiftKey === e.shiftKey);
+ let hotkey = options.hotkeys.find(h => h.key.toLowerCase() === e.key.toLowerCase() && h.ctrlKey === e.ctrlKey && h.shiftKey === e.shiftKey);
if (hotkey !== undefined) {
if (hotkey.preventDefault) {
e.preventDefault();
diff --git a/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.js.map b/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.js.map
index dd92a7e..8b12550 100644
--- a/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.js.map
+++ b/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.js.map
@@ -1 +1 @@
-{"version":3,"file":"hotkeymanager.js","sourceRoot":"","sources":["hotkeymanager.ts"],"names":[],"mappings":";;;;;;;;;AAAA,IAAI,aAAa,CAAC;AAClB,IAAI,OAA6B,CAAC;AAElC,MAAM,UAAU,WAAW,CAAC,qBAAqB,EAAE,oBAA0C;IACzF,aAAa,GAAG,qBAAqB,CAAC;IACtC,OAAO,GAAG,IAAI,oBAAoB,CAAC,oBAAoB,CAAC,SAAS,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACjG,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;QAC7B,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAChE,CAAC;AACL,CAAC;AAED,MAAM,UAAU,OAAO;IACnB,aAAa,GAAG,IAAI,CAAC;IACrB,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;QAC7B,QAAQ,CAAC,mBAAmB,CAAC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,EAAE,cAAc,GAAG,KAAK;QAC9E,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;CACJ"}
\ No newline at end of file
diff --git a/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.ts b/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.ts
index a0a4a7d..3b206f6 100644
--- a/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.ts
+++ b/Json_exe.Blazor.HotkeyManager/wwwroot/hotkeymanager.ts
@@ -26,7 +26,7 @@ async function keyDownEvent(e: KeyboardEvent) {
if (options.hotkeys.length <= 0) {
return
}
- let hotkey = options.hotkeys.find(h => h.key.toLowerCase() === e.key && h.ctrlKey === e.ctrlKey && h.shiftKey === e.shiftKey);
+ let hotkey = options.hotkeys.find(h => h.key.toLowerCase() === e.key.toLowerCase() && h.ctrlKey === e.ctrlKey && h.shiftKey === e.shiftKey);
if (hotkey !== undefined) {
if (hotkey.preventDefault) {
e.preventDefault()