dom / latest / xrinputsourceevent / xrinputsourceevent.html /

XRInputSourceEvent()

The XRInputSourceEvent() constructor creates and returns a new XRInputSourceEvent object describing an event (state change) which has occurred on a WebXR user input device represented by an XRInputSource.

Syntax

new XRInputSourceEvent(type, eventInitDict)

Parameters

type

A DOMString indicating which of the input source events the new object will represent. Permitted values are listed under Event types below.

eventInitDict

An object to configure the event with the following properties:

  • frame: An XRFrame object representing the event frame during which the event took place. This event is not associated with the animation process, and has no viewer information contained within it.
  • inputSource: An XRInputSource object representing the input device from which the event is being sent.

Return value

A new XRInputSourceEvent object representing the event described by the given type and eventInitDict.

Event types

select

Sent to an XRSession when the sending input source has fully completed a primary action.

selectend

Sent to an XRSession when an ongoing primary action ends, or when an input source with an ongoing primary action has been disconnected from the system.

selectstart

Sent to an XRSession when an input source begins its primary action, indicating that the user has begun a command-like input, such as pressing a trigger or button, issuing a spoken command, tapping on a touchpad, or the like.

squeeze

Sent to an XRSession when the sending input source has fully completed a primary squeeze action.

squeezeend

Sent to an XRSession when an ongoing primary squeeze action ends or when an input source with an ongoing primary squeeze action is disconnected.

squeezestart

Sent to an XRSession when an input source begins its primary squeeze action, indicating that the user has begun to grab, squeeze, or grip the controller.

Examples

This example creates a new select event and sends it to the XRSession.

let event = new XRInputSourceEvent("select", {
  frame: eventFrame,
  inputSource: source
};
if (event) {
  xrSession.dispatchEvent(event);
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
XRInputSourceEvent
79
79
No
No
No
No
No
79
No
No
No
11.2

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourceEvent/XRInputSourceEvent