macOS shortcuts: Only listen for command key, not control key

This commit is contained in:
Scott Nonnenberg 2019-12-17 10:52:36 -08:00 committed by Ken Powers
parent d86e8ef7ec
commit 2c7baad68d
10 changed files with 59 additions and 39 deletions

View file

@ -1,6 +1,6 @@
import * as React from 'react';
import { Editor } from 'draft-js';
import { noop } from 'lodash';
import { get, noop } from 'lodash';
import classNames from 'classnames';
import {
EmojiButton,
@ -293,9 +293,12 @@ export const CompositionArea = ({
const { key, shiftKey, ctrlKey, metaKey } = e;
// When using the ctrl key, `key` is `'X'`. When using the cmd key, `key` is `'x'`
const xKey = key === 'x' || key === 'X';
const cmdOrCtrl = ctrlKey || metaKey;
const commandKey = get(window, 'platform') === 'darwin' && metaKey;
const controlKey = get(window, 'platform') !== 'darwin' && ctrlKey;
const commandOrCtrl = commandKey || controlKey;
// cmd/ctrl-shift-x
if (xKey && shiftKey && cmdOrCtrl) {
if (xKey && shiftKey && commandOrCtrl) {
e.preventDefault();
setLarge(x => !x);
}