Connected to: bevyengine/bevy#23421
Description
I am trying to detect pinch to zoom gestures when using winit on the web. This is problematic because pinch to zoom gestures use the same MouseWheel event scrolling uses. The only difference is that event.ctrlKey is set.
This results in a hacky solution to try to detect whether the control key is pressed by listening to two separate events.
Solution
Adding modifier state directly to the MouseWheel event and other events similar to it would allow higher ease of use for situations such as this one. Another solution could be to expose just a variable called is_pinching that represents the control key.
A new proposed solution is to send a pinch event when the ctrlKey modifier is sent during the event.
Example JS Code
// current
document.addEventListener('wheel', (e) => {
dispatchModifiers(...)
dispatchWheelEvent({ x: e.deltaX, y: e.deltaY });
});
// proposed
document.addEventListener('wheel', (e) => {
dispatchModifiers(...)
if (!e.ctrlKey) dispatchWheelEvent({ x: e.deltaX, y: e.deltaY, modifiers: ... });
else dispatchPinchEvent({ … });
});
Connected to: bevyengine/bevy#23421
Description
I am trying to detect pinch to zoom gestures when using
winiton the web. This is problematic because pinch to zoom gestures use the sameMouseWheelevent scrolling uses. The only difference is thatevent.ctrlKeyis set.This results in a hacky solution to try to detect whether the control key is pressed by listening to two separate events.
Solution
Adding modifier state directly to theMouseWheelevent and other events similar to it would allow higher ease of use for situations such as this one. Another solution could be to expose just a variable calledis_pinchingthat represents the control key.A new proposed solution is to send a pinch event when the
ctrlKeymodifier is sent during the event.Example JS Code