I have buttons that use the react library react-ink
with onClick canvas animation. That animation only works when button is clicked by mouse(cursor). In my view I use buttons that have a hotkey assigned to them and I need to trigger "click" animation even when I click hotkey on my keyboard.
I tried to use dispatchEvent
to simulate click on proper height and width but its doesn't work
my example:
const el = wrapperRef.current.querySelectorAll(`[data-target="${value.id}"]`)[0]
const elPosition = el.getBoundingClientRect();
const evt = new MouseEvent("mousedown", {
'view': window,
'bubbles': true,
'cancelable': true,
'screenX': elPosition.left,
'screenY': elPosition.top
});
el.dispatchEvent(evt);
// button
<div
data-target={props.values.id}
role="button">
<Ink hasTouch={false} />
</div>