splinetool / react-spline

React component for Spline scenes.
MIT License
1.19k stars 59 forks source link

Emitting a keyDown or keyUp event with a specific key #124

Open eric-normal opened 1 year ago

eric-normal commented 1 year ago

According to the doc, emitEvent takes in an event name, but this won't work with the keyup or keydown event when you need to specific a key as well.

yuki-katayama commented 6 months ago

Based on the documentation from the link, the SPEObject in @splinetool/runtime has the following method:

/**
 * Triggers a Spline event.
 * Starts from first state to last state.
 * @param {string} eventName String that matches the Spline event's name
 * @param {string} uuid String to match to the object's uuid
 */
emitEvent: (eventName: SplineEventName) => void;

Thus, it appears necessary to ensure compatibility with this implementation. However, it may be required to align the event details on the Spline side as well....

Kagigz commented 2 months ago

Hi, I'm also having the same issue. I need to emit a keyDown with a specific key but can't find how to do it in the documentation.

gcalabria commented 1 week ago

This issue is more than one year old. There still no solution for this?

gcalabria commented 1 week ago

Here is a really hacky workaround that I've found: document.dispatchEvent(new KeyboardEvent("keydown", { key: "l" }))