diff --git a/core/input/keyboard.js b/core/input/keyboard.js index 48f65cf6..0e1e6370 100644 --- a/core/input/keyboard.js +++ b/core/input/keyboard.js @@ -40,6 +40,13 @@ export default class Keyboard { if (down) { this._keyDownList[code] = keysym; } else { + // On MacOs zoom and shortcut actions are CMD based so we need to + // let the remote know that it should unselect the CTRL key instead + if (browser.isMac() && code === "MetaLeft" && this._keyDownList["ControlLeft"]) { + keysym = KeyTable.XK_Control_L; + code = "ControlLeft"; + } + // Do we really think this key is down? if (!(code in this._keyDownList)) { return; diff --git a/core/rfb.js b/core/rfb.js index 24af1f75..da8ce5be 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -10,7 +10,7 @@ import { toUnsigned32bit, toSigned32bit } from './util/int.js'; import * as Log from './util/logging.js'; import { encodeUTF8, decodeUTF8 } from './util/strings.js'; -import { dragThreshold, supportsCursorURIs, isTouchDevice } from './util/browser.js'; +import { dragThreshold, supportsCursorURIs, isTouchDevice, isMac } from './util/browser.js'; import { clientToElement } from './util/element.js'; import { setCapture } from './util/events.js'; import EventTargetMixin from './util/eventtarget.js'; @@ -1340,6 +1340,12 @@ export default class RFB extends EventTargetMixin { this._accumulatedWheelDeltaX += dX; this._accumulatedWheelDeltaY += dY; + // On MacOs we need to translate zooming CMD+wheel to CTRL+wheel + if (isMac() && this._keyboard._keyDownList["MetaLeft"]) { + this._keyboard._sendKeyEvent(this._keyboard._keyDownList["MetaLeft"], "MetaLeft", false); + this._keyboard._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true); + } + // Generate a mouse wheel step event when the accumulated delta // for one of the axes is large enough. if (Math.abs(this._accumulatedWheelDeltaX) >= WHEEL_STEP) {