From 37d0393231d087ba8d5a72ceeb18427c6c94dc6c Mon Sep 17 00:00:00 2001 From: Bill Wallace Date: Tue, 29 Nov 2022 10:46:49 -0600 Subject: [PATCH] Update for PR --- .../shared/getMouseModifier.ts | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/tools/src/eventDispatchers/shared/getMouseModifier.ts b/packages/tools/src/eventDispatchers/shared/getMouseModifier.ts index 019dd25f60..43259b849c 100644 --- a/packages/tools/src/eventDispatchers/shared/getMouseModifier.ts +++ b/packages/tools/src/eventDispatchers/shared/getMouseModifier.ts @@ -5,14 +5,26 @@ import { KeyboardBindings as kb } from '../../enums'; * Supports Shift, Ctrl, Alt, in singly and in combinations of 2 * Supports Meta singly. */ -const getMouseModifierKey = (evt) => - (evt.shiftKey && - ((evt.ctrlKey && kb.ShiftCtrl) || - (evt.altKey && kb.ShiftAlt) || - kb.Shift)) || - (evt.ctrlKey && ((evt.altKey && kb.CtrlAlt) || kb.Ctrl)) || - (evt.altKey && kb.Alt) || - (evt.metaKey && kb.Meta) || - undefined; +const getMouseModifierKey = (evt) => { + // The logic is a hard coded key mapping + if (evt.shiftKey) { + if (evt.ctrlKey) return kb.ShiftCtrl; + if (evt.altKey) return kb.ShiftAlt; + if (evt.metaKey) return kb.ShiftMeta; + return kb.Shift; + } + if (evt.ctrlKey) { + if (evt.altKey) return kb.CtrlAlt; + if (evt.metaKey) return kb.CtrlMeta; + return kb.Ctrl; + } + if (evt.altKey) { + return (evt.metaKey && kb.AltMeta) || kb.Alt; + } + if (evt.metaKey) { + kb.Meta; + } + return undefined; +}; export default getMouseModifierKey;