buttonIndex in onPointerDownObservable

Hello,
i am trying to add some modifier keys to the Items of a button UI.
I found the buttonIndex property as in:

ell.onPointerDownObservable.add(function(evt){
	if(evt.buttonIndex==2){
		// make him an offer he can't refuse ( );
	}
})

however this buttonIndex only works for ctrl/secondary mouse it seems?
Or is there a way to get option, command, shift, etc?
Thanky!

hello do you mind reproducing in the playground?

No P.
Here you are:
https://playground.babylonjs.com/#FB1P78

well it works directly for me :frowning:

so you are getting indices other than 0?

yep :slight_smile:

hm.
with macos i am getting only “0” on most browsers ( Safari, Firefox, Chrome ) Only Waterfox 56.3 gives me “2” when ctrl-clicking.
On Windows only Edge gives me “2” when alt-clicking.

Pinging @cedric to check what is going on on Mac:)

Let me check that :slight_smile:

But even on Windows I only get Alt. Not Shift, not ctrl…

Hi @EvilTwinsNiceBrother

buttonIndex is the mouse button used for clicking (0 = left click, 1 = middle button, 2 = right button), this has nothing to do with ctrl/shift/alt key pressed while clicking. I checked on Windows (FF, Chrome, Edge) and Mac (Safari). All behave the same. Maybe I’m missing the same.
If you want to check keyboard key pressed while clicking, you can check Events handling Event Handling - Babylon.js Documentation
I don’t know if there is a better/simpler way to check the key pressed.

Ah, I see. Thanks. A misunderstanding, since the onPointerObservable passes the modifier keys.
Seems that the GUI has a different logic

Oh yeah I did not get that you wanted modifiers keys:(