Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. XRSession
  4. inputsourceschange

XRSession: inputsourceschange event

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Theinputsourceschange event is sent to anXRSession when the set of available WebXR input devices changes.

Syntax

Use the event name in methods likeaddEventListener(), or set an event handler property.

js
addEventListener("inputsourceschange", (event) => { })oninputsourceschange = (event) => { }

Event type

AnXRInputSourcesChangeEvent. Inherits fromEvent.

Event XRInputSourcesChangeEvent

Event properties

In addition to the properties listed below, properties from the parent interface,Event, are available.

addedRead only

An array of zero or moreXRInputSource objects, each representing an input device which has been recently connected or enabled.

removedRead only

An array of zero or moreXRInputSource objects representing the input devices recently disconnected or disabled.

sessionRead only

TheXRSession to which this input source change event is being directed.

Description

Trigger

Triggered when the set of available WebXR input devices changes.

Use cases

You can use this event to detect newly-available devices or when devices have become unavailable.

Examples

The following example shows how to set up an event handler which usesinputsourceschange events to detect newly-available pointing devices and to load their models in preparation for displaying them in the next animation frame.

js
xrSession.addEventListener("inputsourceschange", onInputSourcesChange);function onInputSourcesChange(event) {  for (const input of event.added) {    if (input.targetRayMode === "tracked-pointer") {      loadControllerMesh(input);    }  }}

You can also add a handler forinputsourceschange events by setting theoninputsourceschange event handler:

js
xrSession.oninputsourceschange = onInputSourcesChange;

Specifications

Specification
WebXR Device API
# eventdef-xrsession-inputsourceschange
WebXR Device API
# dom-xrsession-oninputsourceschange

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp