This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The WebXR Device API's XRInputSourceEvent interface describes an event which has occurred on a WebXR user input device such as a hand controller, gaze tracking system, or motion tracking system. More specifically, they represent a change in the state of an XRInputSource.
To learn more about handling inputs in a WebXR project, see the article Inputs and input sources.
XRInputSourceEvent()Creates and returns a new XRInputSourceEvent object whose properties match those provided in the eventInitDict dictionary provided.
frame Read only
An XRFrame object providing the needed information about the event frame during which the event occurred. This frame may have been rendered in the past rather than being a current frame. Because this is an event frame, not an animation frame, you cannot call the XRFrame method getViewerPose() on it; instead, use getPose().
inputSource Read only
An XRInputSource object indicating which input source generated the input event.
The XRInputSourceEvent interface doesn't define any methods; however, several methods are inherited from the parent interface, Event.
selectSent to an XRSession when the sending input source has fully completed a primary action.
selectendSent 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.
selectstartSent 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.
squeezeSent to an XRSession when the sending input source has fully completed a primary squeeze action.
squeezeendSent to an XRSession when an ongoing primary squeeze action ends or when an input source with an ongoing primary squeeze action is disconnected.
squeezestartSent 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.
The code below sets up handlers for primary action events in order to determine when the user clicks on (shoots at/pokes at/whatever) objects in the scene.
xrSession.addEventListener("select", (event) => {
let targetRayPose = event.frame.getPose(
event.inputSource.targetRaySpace,
myRefSpace,
);
if (targetRayPose) {
let hit = myHitTest(targetRayPose.transform);
if (hit) {
/* handle the hit */
}
}
});
| Specification |
|---|
| WebXR Device API> # xrinputsourceevent-interface> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
XRInputSourceEvent |
79 | 79 | No | 66 | No | 79 | No | 57 | No | 11.2 | No | No |
XRInputSourceEvent |
79 | 79 | No | 66 | No | 79 | No | 57 | No | 11.2 | No | No |
frame |
79 | 79 | No | 66 | No | 79 | No | 57 | No | 11.2 | No | No |
inputSource |
79 | 79 | No | 66 | No | 79 | No | 57 | No | 11.2 | No | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourceEvent