Fix several shortcuts not working with non-EN keyboard layouts

This commit is contained in:
Vladislav Gorenkin 2022-03-31 11:58:28 +06:00
parent 308cef086c
commit d094a93191
No known key found for this signature in database
GPG key ID: 5D6BB801BEC779D6
6 changed files with 22 additions and 9 deletions

View file

@ -56,6 +56,7 @@ import {
import { MediaEditor } from './MediaEditor';
import { IMAGE_PNG } from '../types/MIME';
import { isImageTypeSupported } from '../util/GoogleChrome';
import * as KeyboardLayout from '../services/keyboardLayout';
export type CompositionAPIType =
| {
@ -451,7 +452,8 @@ export const CompositionArea = ({
// Listen for cmd/ctrl-shift-x to toggle large composition mode
useEffect(() => {
const handler = (e: KeyboardEvent) => {
const { key, shiftKey, ctrlKey, metaKey } = e;
const { shiftKey, ctrlKey, metaKey } = e;
const key = KeyboardLayout.lookup(e);
// When using the ctrl key, `key` is `'X'`. When using the cmd key, `key` is `'x'`
const xKey = key === 'x' || key === 'X';
const commandKey = get(window, 'platform') === 'darwin' && metaKey;