Telerik XR CanvasUI provides a keyboard prefab that allows you to show a virtual keyboard when the XR user selects an input field.

Keyboard Prefab

The keyboard prefab is installed through simple dragging and dropping into the scene hierarchy. By default, its UI children are hidden, however, when the user clicks on an input field, the Keyboard component automatically repositions the prefab below the input field and shows the keyboard UI. The following input fields are currently supported:

The keyboard is hidden when:

  • The EventSystem.current.currentSelectedGameObject is null.

  • The EventSystem.current.currentSelectedGameObject is not of the InputField or TextMeshPro InputField type.

You can hide the keyboard either programmatically or by clicking on another UI element (for instance, on a Dropdown).

Key Prefab

All of the keyboard keys are created by using the Key prefab. This prefab is drawing the key text by using TextMeshPro. It also has an attached Key component. The Key component is responsible for handling the pointer events and for providing the KeyCode and character code information for the corresponding key.

Receiving Input

Each of the keys implements IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, and IPointerUpHandler interfaces for handling Unity pointer events. Additionally, the Keyboard prefab has a TouchSurfaceCanvas component to allow close distance finger interactions when using hand tracking.

The pointers logic is not included in the Telerik XR CanvasUI package. However, in the Telerik XR Interactions package, you may find easy-to-setup pointers for both distant interactions and close-distance finger interactions. This package may be purchased from the Unity Asset Store either standalone or as part of the Telerik XR Complete solution.

Customizing the Layout

To customize the layout of the keyboard:

  • Add/Remove/Reposition the Key prefab instances.

  • Edit the Key Code property values of the Key component.

  • Edit the Character property values of the Key component.

In this article
Not finding the help you need?