Develop
Develop
Select your platform

Virtual Keyboard Sample Overview

Virtual Keyboard Deprecation
Virtual Keyboard as a feature is being deprecated in favor of the system keyboard overlay in Unity.
Please see System Keyboard Overlay for instructions on enabling the system keyboard as an overlay in Unity.
The Virtual Keyboard sample scene is available in the Meta XR Core SDK. Download the Meta XR Core SDK from the Unity Asset Store or Meta’s NPM registry website.
Install the downloaded asset packages in Unity using Unity Package Manager. For more details, see Import SDKs with Unity Package Manager.
Import the sample scene into your Unity project by following these steps:
  1. Go to Window > Package Manager and filter for My Assets.
  2. Select Meta XR SDK Core > Samples > Import next to the listed samples.
  3. On the Project tab, go to Assets/Samples/Meta XR Core SDK/65.0.0/Sample Scenes/ to open the VirtualKeyboard.unity scene or search for Virtual Keyboard in the search field with the filter set as All.
Note
Uncheck Requires System Keyboard in the Quest Features section of OVRCameraRig. Otherwise, the sample won’t work.
This sample scene displays:
  • Two text fields where you can type.
  • Preconfigured support for both hands and controllers.
  • Controls to change the keyboard placement between far and direct input.
  • Controls to demonstrate moving the keyboard with a custom script.
  • Controls to demonstrate hiding, showing, and destroying the keyboard.
When the sample first starts up, you will see a virtual keyboard positioned in front of you configured for far input. This keyboard’s transform is based on the position of the keyboard’s prefab in the scene.
Use controllers to aim at the keyboard and press the trigger button to hit keys. Hold the trigger button and swipe along keys to input whole words by swiping the ray over the letters used to spell the word.
Virtual Keyboard sample scene
WIth hands you can aim at the keyboard with a hand pointer pose, pinching to select keys. Just like controllers, if you hold your pinch and swipe over keys you can input whole words.
A hand selecting keys on the Virtual Keyboard
Long press on certain keys to bring up additional special key options. For example, letters with diacritics, or symbols.
Pressing shift on the keyboard once will let you input a single uppercase letter. If pressed twice, it puts the keyboard in Caps-Lock mode.
To move the keyboard press the Move Keyboard control button. This will pin the keyboard to your input source at the distance you are from the keyboard. Press it again to place the keyboard in a desired position. If you are using a controller to move the keyboard, move the analog stick up and down to move the keyboard forward and back. Left and right will scale the keyboard up and down. This demonstrates a runtime script repositioning/resizing the keyboard.
The 'move,' 'near,' and 'far' buttons
Press the Near or Far button to move the keyboard to a suggested position provided by the OpenXR Virtual Keyboard API.
Selecting keys on the Virtual Keyboard using a hand pointer pose
If direct input mode is selected, you can push through the keys directly to trigger inputs using a controller. Holding your position to access special keys, or swiping by moving the controller around the keyboard while keeping your depth pressed.
If using hands, you can press keys with your index finger. Hand inputs support poke limiting, which prevents the rendered model of the hand from clipping into the keyboard providing a more natural input feeling. As with controllers, you can long press to access special keys, or move your finger around the keyboard while still pressing to use swipe input.
The Destroy and Show keyboard controls simply demonstrate hiding and showing the keyboard.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon