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

@ -14,6 +14,7 @@ import { StickerPicker } from './StickerPicker';
import { countStickers } from './lib';
import { offsetDistanceModifier } from '../../util/popperUtil';
import { themeClassName } from '../../util/theme';
import * as KeyboardLayout from '../../services/keyboardLayout';
export type OwnProps = {
readonly className?: string;
@ -151,10 +152,11 @@ export const StickerButton = React.memo(
// Install keyboard shortcut to open sticker picker
React.useEffect(() => {
const handleKeydown = (event: KeyboardEvent) => {
const { ctrlKey, key, metaKey, shiftKey } = event;
const { ctrlKey, metaKey, shiftKey } = event;
const commandKey = get(window, 'platform') === 'darwin' && metaKey;
const controlKey = get(window, 'platform') !== 'darwin' && ctrlKey;
const commandOrCtrl = commandKey || controlKey;
const key = KeyboardLayout.lookup(event);
// We don't want to open up if the conversation has any panels open
const panels = document.querySelectorAll('.conversation .panel');