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

@ -1,6 +1,8 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as KeyboardLayout from '../../services/keyboardLayout';
export function handleKeydownForSearch(
event: Readonly<KeyboardEvent>,
{
@ -13,13 +15,14 @@ export function handleKeydownForSearch(
startSearch: () => unknown;
}>
): void {
const { ctrlKey, metaKey, shiftKey, key } = event;
const { ctrlKey, metaKey, shiftKey } = event;
const commandKey = window.platform === 'darwin' && metaKey;
const controlKey = window.platform !== 'darwin' && ctrlKey;
const commandOrCtrl = commandKey || controlKey;
const commandAndCtrl = commandKey && ctrlKey;
const key = KeyboardLayout.lookup(event);
if (commandOrCtrl && !commandAndCtrl && key.toLowerCase() === 'f') {
if (commandOrCtrl && !commandAndCtrl && (key === 'f' || key === 'F')) {
if (!shiftKey) {
startSearch();
event.preventDefault();