Impossible to detect mousedown and mouseup events

I don’t understand why i can’t detect the mousedown and mouseup events on Chrome.

An example of code is here :

https://playground.babylonjs.com/#3YE0SW

I would have preferred to use Pointer events but i need the right click event (context menu event) and i don’t know how to simulate right click event with pointer events.

Could you help me ?

Thank you.

I was looking at the PG and I’m not quite sure why mousedown/up isn’t working but if you’re trying to catch and filter right-click specific events, you can do it with pointerdown/up:

canvas.addEventListener("pointerdown", function(e) {
    if (e.button === 2) {
        console.log("mousedown");
    }
});

canvas.addEventListener("pointerup", function(e) {
    if (e.button === 2) {
        console.log("mouseup");
    }
});

Here’s a modified form of your PG, showing it in action: Babylon.js Playground (babylonjs.com)

2 Likes

Ok, i will do like this…

Thank you, I also had this issue.