BlazorVirtualKeyboard 1.0.2
dotnet add package BlazorVirtualKeyboard --version 1.0.2
NuGet\Install-Package BlazorVirtualKeyboard -Version 1.0.2
<PackageReference Include="BlazorVirtualKeyboard" Version="1.0.2" />
<PackageVersion Include="BlazorVirtualKeyboard" Version="1.0.2" />
<PackageReference Include="BlazorVirtualKeyboard" />
paket add BlazorVirtualKeyboard --version 1.0.2
#r "nuget: BlazorVirtualKeyboard, 1.0.2"
#addin nuget:?package=BlazorVirtualKeyboard&version=1.0.2
#tool nuget:?package=BlazorVirtualKeyboard&version=1.0.2
Blazor On-Screen Virtual Keyboard
A lightweight on-screen keyboard for Blazor WebAssembly (.NET 8) with minimal JavaScript dependencies.
Supports multiple languages, numeric keypad (numpad) for number inputs, and customizable layouts.
π Current Status:
Blazor WebAssembly is fully supported. Blazor Server support is in progress.
β Note: This is a prototype and may not support all use cases. Due to the interaction between Blazor and JavaScript, only the components FormVirtualKeyboard.razor and InputVirtualKeyboard.razor currently support this keyboard.
β¨ Features
β On-screen virtual keyboard for Blazor WebAssembly
β Supports multiple languages (English, Danish, and more planned)
β Numeric keypad (numpad) support for `<InputVirtualkeyboard Id="number" Type="number/> fields
β Includes special characters (β¬, @, %, &, etc.)
β Customizable keyboard layouts (QWERTY, AZERTY, DVORAK β planned)
β Minimal JavaScript usage for better Blazor integration
β Automatic focus detection β The keyboard activates when an input field is focused
πΈ Screenshots
Alphabetic Layout:
Special Characters:
Numpad:
π¦ Installation
Install the NuGet package in your Blazor WebAssembly project (.NET 8):
dotnet add package BlazorVirtualKeyboard
1οΈβ£ Update Program.cs
Add the following services:
builder.Services.AddHttpClient();
builder.Services.AddScoped<BlazorVirtualKeyboard.Services.VirtualKeyboardService>();
2οΈβ£ Add Namespace
In _Imports.razor
, add:
@using BlazorVirtualKeyboard
3οΈβ£ Add Scripts in index.html
Ensure the following scripts are included:
<script src="_content/BlazorVirtualKeyboard/Components/InputVirtualKeyboard.razor.js"></script>
<script src="_content/BlazorVirtualKeyboard/Components/FormVirtualKeyboard.razor.js"></script>
<script src="_content/BlazorVirtualKeyboard/Keyboards/VirtualKeyboard.razor.js"></script>
(Optional, but recommended) If you want function button icons, include:
<script src="https://kit.fontawesome.com/be5149d719.js" crossorigin="anonymous"></script>
π Usage
Basic Setup
To enable the keyboard globally, add it once in MainLayout.razor
:
<div>
<BlazorVirtualKeyboard.Keyboards.VirtualKeyboard />
</div>
The keyboard remains hidden until a compatible input field is focused.
Form Example (Login)
Hereβs how to integrate it into a form:
<FormVirtualKeyboard FormAction="Login" FormId="loginForm" FormClass="login-form row-1 test-form" EditContext="loginEditContext">
<h5>Login</h5>
<div class="input">
<label for="username" />
<InputVirtualKeyboard @bind-InputValue="LoginModelInstance.Username"
Id="username" Type="text" Placeholder="Username" />
<label for="password" />
<InputVirtualKeyboard @bind-InputValue="LoginModelInstance.Password"
Id="password" Type="password" Placeholder="Password" />
</div>
<div class="action">
<button type="submit" class="bluebtn">
Login
</button>
</div>
</FormVirtualKeyboard>
@code {
public LoginModel? LoginModelInstance = new LoginModel();
private EditContext? loginEditContext;
protected override async Task OnInitializedAsync()
{
loginEditContext = new EditContext(LoginModelInstance);
}
private void Login()
{
if (loginEditContext.Validate())
{
Log.Information($"User: {LoginModelInstance?.Username}, Password: {LoginModelInstance?.Password}");
}
}
public class LoginModel
{
[Required]
[MinLength(3, ErrorMessage = "Username is too short.")]
public string? Username { get; set; }
[Required]
[MinLength(3, ErrorMessage = "Password is too short.")]
public string? Password { get; set; }
}
}
Numeric Keypad Example
For <input type="number">
, you can enable the numpad:
<InputVirtualKeyboard Placeholder="Enter a number" Id="numInput" Type="number"/>
Standalone Input Field
If you just need an input with the virtual keyboard:
<InputVirtualKeyboard Placeholder="Type here" Id="test" Type="text"/>
π Planned Features
- β Blazor Server support (in progress)
- π¨ Customizable layouts (QWERTY, AZERTY, DVORAK, etc.)
- π More language support (user-configurable layouts)
- π’ Expanded numpad functionality (arithmetic operations, decimal input)
- π Theme customization (light/dark mode, colors, CSS variables)
- πΉ Custom keyboard mappings (for specialized applications)
π Troubleshooting
- Keyboard not appearing? Make sure you included the required scripts in
index.html
. - Keyboard not closing? Ensure you donβt have conflicting JavaScript handling focus events.
- Blazor Server not working? Server support is still in development.
π License
This project is licensed under the MIT License.
π€ Contributing
Feel free to report issues, suggest features, or submit pull requests! Contributions are welcome. π
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 was computed. 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 was computed. 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. |
-
net8.0
- Microsoft.AspNetCore.Components (>= 8.0.6)
- Microsoft.AspNetCore.Components.Web (>= 8.0.6)
- Microsoft.Extensions.Http (>= 8.0.0)
- Serilog.Sinks.BrowserConsole (>= 2.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.