files/en-us/web/api/xrinputsourceevent/index.md
{{APIRef("WebXR Device API")}} {{SecureContext_Header}}
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 {{domxref("XRInputSource")}}.
To learn more about handling inputs in a WebXR project, see the article Inputs and input sources.
{{InheritanceDiagram}}
XRInputSourceEvent object whose properties match those provided in the eventInitDict dictionary provided.The XRInputSourceEvent interface doesn't define any methods; however, several methods are inherited from the parent interface, {{domxref("Event")}}.
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 */
}
}
});
{{Specifications}}
{{Compat}}