Skip to content

Input ​

Every control takes the same input, and you handle it once:

InputHow it presses
Mouseclick
Controllerpoint the ray, pull the trigger
Hand, farpoint, pinch thumb and index
Hand, nearpoke the control with a fingertip
KeyboardTab to it, press Enter or Space

All of them fire the same click (or update:modelValue) event.

Press rules ​

  • A press counts on release, however long it is held. Slow, careful presses (common with hands) are not lost.
  • A control keeps the pointer until release, like DOM pointer capture: sliding off a slider while dragging keeps dragging it.
  • A drag never selects: scrolling an <XrList> with a finger does not pick the item under it.
  • A poke sinks the control back by theme.interaction.pressDepth, the visual feedback for touch.

Keyboard ​

The canvas takes keyboard focus like any focusable element: click into the scene, or Tab to it from the page. Then:

KeyDoes
Tab, Shift+TabNext / previous control, in template order; a list scrolls to show it. Disabled and hidden controls are skipped; while a dialog is open, Tab goes round its own controls only. Each radio option is a stop of its own.
Enter, SpacePress the focused control (a button's click, a checkbox toggles, a select opens).
← →Previous / next tab or radio option (it is chosen, and focus follows); a slider steps.
↑ ↓Previous / next option of a select or radio group; a slider steps.
EscapeClose the open select, then the topmost dialog.

A ring in the theme's focusRing colour shows around the focused control after keyboard use, and hides on any pointer press or when focus leaves the canvas. A pointer press also moves focus to what it pressed, so Tab goes on from there. Past the last control Tab goes on to the rest of the page; in a session (a keyboard paired with the headset) it wraps around. A press by keyboard passes a ControlPointerEvent with details.type === 'keyboard'.

Session state ​

ts
const xr = useXr()
xr.isPresenting.value // in a session?
xr.mode.value         // 'immersive-vr' | 'immersive-ar' | null
xr.supported.value    // { vr: boolean, ar: boolean }
xr.systemKeyboard.value // the session has a system keyboard (Quest Browser)
await xr.enterVR()
await xr.enterAR()
await xr.exit()

<XrEnterButton mode="vr"> is a ready-made DOM button for this.

MIT License