UnoKeyboard 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package UnoKeyboard --version 1.0.0
                    
NuGet\Install-Package UnoKeyboard -Version 1.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="UnoKeyboard" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UnoKeyboard" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="UnoKeyboard" />
                    
Project file
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 UnoKeyboard --version 1.0.0
                    
#r "nuget: UnoKeyboard, 1.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.
#addin nuget:?package=UnoKeyboard&version=1.0.0
                    
Install UnoKeyboard as a Cake Addin
#tool nuget:?package=UnoKeyboard&version=1.0.0
                    
Install UnoKeyboard as a Cake Tool

UnoKeyboard

UnoKeyboard is an on-screen virtual keyboard designed for Desktop, WASM, and Windows platforms.

UnoKeyboardDark UnoKeyboardDark

Features

  • Multi-platform support.
  • Customizable layout.
  • Theme support.
  • Customizable appearance (font and size).

Usage

This library provides an extension method for the Window class to display the virtual keyboard.

The method generates a scaffold with the keyboard layout and adds it to the Window content. You can then use the new RootFrame to publish your actual content.

To activate the main window, add the following line to your App.xaml.cs file. The control manages focus events using FocusManager, so the keyboard will be shown whenever any TextBox control gets the focus.

// Once the keyboard is added to the window, users should use RootFrame to add new content.
public static Frame RootFrame => McWindowEx.RootFrame;

MainWindow.AddKeyboard(height: 300);

// Navigate using McWindowEx.RootFrame
if (RootFrame.Content == null)
{
    RootFrame.Navigate(typeof(MainPage), args.Arguments);
}

The extension class McWindowEx introduces a new attached property KeyboardType that allows keyboard customization. Two default keyboards are provided:

  • en-alfa
  • numeric

To use a specific keyboard, set the attached property KeyboardType in your TextBox control. By default, the keyboard is set to en-alfa:

<Page 
    xmlns:mck="using:UnoKeyboard" />

<TextBox Width="200"
         VerticalAlignment="Center"
         FontSize="30"
         mck:McWindowEx.KeyboardType="numeric" />

Customization

Two static dictionaries are used to define the Keyyboard and the Keys. You can add more keys and keyboard layouts by adding new entries to these dictionaries.

VirtualKeys

VirtualKeys.Key dictionary defines the keys that will be displayed on the keyboard. Each key is defined by a VirtualKeyModel.

That is a reduced version of the dictionary:

public static class VirtualKeys
{
    public static Dictionary<string, VirtualKeyModel> Key = new()
    {
        { "N1", new VirtualKeyModel("N1", KeyType.Text, "1", "1", 0x0031, 0x0031, null, 0, 0) },
        { "N2", new VirtualKeyModel("N2", KeyType.Text, "2", "2", 0x0032, 0x0032, null, 0, 0) },
    }
}

Now let say you want to add the key | to your own keyboard layout:

VirtualKeys.Key.Add("|",                // Dictionary key
    new VirtualKeyModel("|",            // Key Id
                        KeyType.Text,   // Type
                        "|",            // Upper Case
                        "|",            // Lower Case
                        0x007C,         // Upper Case Unicode
                        0x007C,         // Lower Case Unicode
                        null,           // PathGeometry for special keys
                        0,              // Width of geometry path.
                        0));            // Height of geometry path.

Keyboards

The Keyboards.Keyboard dictionary defines the keyboard layouts. Each keyboard is defined by a KeyboardModel.

Lets add the new key to the keyboard layout:

Keyboards.Keyboard.Add("my_keyboard",   // Dictionary key
    new KeyboardModel("my_keyboard"     // Keyboard Id
                      "1",              // Number of pages.
                      "3",              // Number of rows.
                      "10",             // Max. keys per row.
                      [
                        new KeyModel(0,                     // Page 0
                                     0,                     // Row 0
                                     1,                     // Column 1
                                     1,                     // Column span
                                     VirtualKeys.Get("|")), // Key
                      ]));

Automatic Keyboard Appearance and Disappearance

The on-screen keyboard automatically appears whenever a TextBox gains focus and disappears when it loses focus. This behavior is controlled by the HandleFocusManager property of the keyboard control.

How it works:

When HandleFocusManager is set to true, the keyboard control actively monitors the focus state of elements within your application. As soon as a TextBox receives focus, the keyboard is automatically displayed to facilitate user input. Conversely, when the focus shifts to another element, the keyboard gracefully disappears, providing a clean and uncluttered interface.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-browserwasm1.0 is compatible.  net8.0-desktop1.0 is compatible.  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.  net8.0-windows10.0.19041 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.9 163 4/8/2025
1.0.8 185 3/10/2025
1.0.7 173 3/9/2025
1.0.6 137 10/5/2024
1.0.5 140 8/24/2024
1.0.4 124 8/22/2024
1.0.2 130 8/20/2024
1.0.1 152 8/14/2024 1.0.1 is deprecated because it is no longer maintained.
1.0.0 148 8/14/2024 1.0.0 is deprecated because it is no longer maintained.