Check if PointerEventTypes.POINTERTAP comes from left or right mouse button

BABYLON.PointerEventTypes.POINTERTAP is triggered independently if the user clicked in a mobile device, or a computer, that’s ok but there is any chance to know if the user pressed left or right mouse click on PC?

Thank you in advance.

It seems these PointerEventTypes are not available yet in the Babylon API.
You could use the event.button-property:

 scene.onPointerObservable.add((pointerInfo) => {
		switch (pointerInfo.type) {
			case BABYLON.PointerEventTypes.POINTERTAP:
                switch (pointerInfo.event.button) {
                    case 0: 
                    case 1: 
                    case 2: 

Consider that event.which property also works, but is deprecated!

1 Like

It seems that pointerInfo.event.button returns a number but thank you so much!

Did you try the provided code above? :thinking:

Thats why I used a switch clause :wink:
You have to interpret the returned numbers with some sort of condition!

The PointerEventTypes are also just static constants, containing a number (like Enums)

1 Like

Sorry my bad! I just copied pointerInfo.event.button and compared with “LEFT” :roll_eyes:

1 Like