Mouse down events not working

I am trying to figure out the best way to receive input. Currently when I add an event listener to the document or window it works for key events, but not mouse events. The screenshot is from the start method.

Original Post on Discord

by user 389107137038516236

I think internally mouse events are currently captured and the default is prevented on the needle-engine element. Can you try if it works on “this.context.domElement”? I think i could previously still receive mouse input events on window too but maybe i remember it wrong. Ill check in a few hours when im at the office and also see why the preventDefault is still there.

In the meantime you can poll it with this.context.input.getPointerDown(0) in e.g. update() for example which will also give you events for XRControllers (AR and VR).

I tried both of these and it did not work for me.

by user 389107137038516236

Is this in a component update loop? (E.g. update(), lateUpdate(), earlyUpdate()) and the component is added to some object in your scene?

I tried both in the update and the start.

by user 389107137038516236

Just tried here again to verify that it works. Are you sure your script is in the scene and the update loop is being called?

I’ve removed the preventDefault in our input code and also started adding some events so you can subscribe to this.context.input.addEventListener("pointerdown", evt => ...) or just use the document.addEventListener("mousedown", ...) code you’ve written above if you prefer that.
will be in the next update

I am sure the update loop is being called. I have other code in it that is functioning as it should be.

by user 389107137038516236

Ok. Can you try the new update?
document.addEventListener(“mousedown”…) Should work there too.

And maybe send me the script? Im curious why it wouldnt work.