Capturing mousedown (and mouseup) event

Ok, here is another one: I’d like to change the color of a bar in a bar chart plot (actually, I’d like to gray out all other bars) when clicking and holding the click, then go back to “normal” when releasing the click. However, it seems that plotly does not have a mousedown event. The solution suggested here also does not work, as I’d need information of the bar that is clicked to be able to selectively change the color. Is there a way to achieve this?

Here I have an example of how I captured the mousemove event of the bars, but to perform other actions, it may be useful to you.

https://codepen.io/saratoga01/pen/abgzeQV

Oh, I see, you create the events yourself! That’s very interesting! It works if I change mousemove to mousedown or mouseup, I just have to check how to trigger both at the same time. Thank you!

Check this

https://codepen.io/saratoga01/pen/NPWzWNz?editors=0010

Aha! I was trying something similar, but with the dispatchEvent, like

        bars[i].onmousedown = e => {
          if(layer._fullLayout._lasthover)
            layer._fullLayout._lasthover.dispatchEvent(new MouseEvent("mousedown", e))
        }
        bars[i].onmouseup = e => {
          if(layer._fullLayout._lasthover)
            layer._fullLayout._lasthover.dispatchEvent(new MouseEvent("mouseup", e))
        }

and for some reason (I don’t really understand), that only triggers the mousedown event - regardless of the order. But it seems I don’t need that at all! Thanks!