Back to Content

XRInputSource: hand property

files/en-us/web/api/xrinputsource/hand/index.md

latest903 B
Original Source

{{APIRef("WebXR Device API")}}{{SecureContext_Header}}

The read-only hand property of the {{domxref("XRInputSource")}} interface is a {{domxref("XRHand")}} object providing access to a hand-tracking device.

Value

An {{domxref("XRHand")}} object or null if the {{domxref("XRSession")}} has not been requested with the hand-tracking feature descriptor.

Examples

js
navigator.xr
  .requestSession({ optionalFeatures: ["hand-tracking"] })
  .then(/* … */);

function renderFrame(session, frame) {
  // …

  for (const inputSource of session.inputSources) {
    if (inputSource.hand) {
      // render a hand model, perform gesture detection, etc.
    }
  }
}

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("XRHand")}}