2016-04-05 15:14:11 +03:00
|
|
|
/*
|
2024-09-09 16:57:16 +03:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2019-12-16 20:14:03 +03:00
|
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
2024-09-09 16:57:16 +03:00
|
|
|
Copyright 2017 New Vector Ltd
|
|
|
|
Copyright 2016 OpenMarket Ltd
|
2016-04-05 15:14:11 +03:00
|
|
|
|
2024-09-09 16:57:16 +03:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2016-04-05 15:14:11 +03:00
|
|
|
*/
|
|
|
|
|
2023-02-13 14:39:16 +03:00
|
|
|
import React from "react";
|
|
|
|
|
2019-09-30 18:04:06 +03:00
|
|
|
export const Key = {
|
|
|
|
HOME: "Home",
|
2019-10-09 21:59:11 +03:00
|
|
|
END: "End",
|
2019-09-30 18:04:06 +03:00
|
|
|
PAGE_UP: "PageUp",
|
|
|
|
PAGE_DOWN: "PageDown",
|
2019-10-04 13:47:33 +03:00
|
|
|
BACKSPACE: "Backspace",
|
2020-03-26 10:37:46 +03:00
|
|
|
DELETE: "Delete",
|
2019-10-09 21:59:11 +03:00
|
|
|
ARROW_UP: "ArrowUp",
|
|
|
|
ARROW_DOWN: "ArrowDown",
|
2019-10-17 17:53:39 +03:00
|
|
|
ARROW_LEFT: "ArrowLeft",
|
|
|
|
ARROW_RIGHT: "ArrowRight",
|
2024-07-17 16:46:45 +03:00
|
|
|
F6: "F6",
|
2019-10-09 21:59:11 +03:00
|
|
|
TAB: "Tab",
|
|
|
|
ESCAPE: "Escape",
|
2019-10-04 13:47:33 +03:00
|
|
|
ENTER: "Enter",
|
2019-10-09 21:59:11 +03:00
|
|
|
ALT: "Alt",
|
|
|
|
CONTROL: "Control",
|
|
|
|
META: "Meta",
|
|
|
|
SHIFT: "Shift",
|
2019-12-02 13:01:08 +03:00
|
|
|
CONTEXT_MENU: "ContextMenu",
|
2019-09-30 18:04:06 +03:00
|
|
|
|
2019-12-16 20:14:03 +03:00
|
|
|
COMMA: ",",
|
2020-03-20 03:18:24 +03:00
|
|
|
PERIOD: ".",
|
2019-10-09 21:59:11 +03:00
|
|
|
LESS_THAN: "<",
|
|
|
|
GREATER_THAN: ">",
|
|
|
|
BACKTICK: "`",
|
|
|
|
SPACE: " ",
|
2020-03-18 19:40:21 +03:00
|
|
|
SLASH: "/",
|
2020-04-11 20:57:59 +03:00
|
|
|
SQUARE_BRACKET_LEFT: "[",
|
|
|
|
SQUARE_BRACKET_RIGHT: "]",
|
2022-03-08 18:05:36 +03:00
|
|
|
SEMICOLON: ";",
|
2019-12-16 20:14:03 +03:00
|
|
|
A: "a",
|
2019-10-09 21:59:11 +03:00
|
|
|
B: "b",
|
2019-12-16 20:14:03 +03:00
|
|
|
C: "c",
|
|
|
|
D: "d",
|
|
|
|
E: "e",
|
|
|
|
F: "f",
|
|
|
|
G: "g",
|
|
|
|
H: "h",
|
2019-10-09 21:59:11 +03:00
|
|
|
I: "i",
|
2019-12-16 20:14:03 +03:00
|
|
|
J: "j",
|
2019-09-30 18:04:06 +03:00
|
|
|
K: "k",
|
2019-12-16 20:14:03 +03:00
|
|
|
L: "l",
|
|
|
|
M: "m",
|
|
|
|
N: "n",
|
|
|
|
O: "o",
|
|
|
|
P: "p",
|
|
|
|
Q: "q",
|
|
|
|
R: "r",
|
|
|
|
S: "s",
|
|
|
|
T: "t",
|
|
|
|
U: "u",
|
|
|
|
V: "v",
|
|
|
|
W: "w",
|
|
|
|
X: "x",
|
2019-10-09 21:59:11 +03:00
|
|
|
Y: "y",
|
|
|
|
Z: "z",
|
2016-04-05 15:14:11 +03:00
|
|
|
};
|
2017-12-01 13:30:49 +03:00
|
|
|
|
2022-05-04 00:04:37 +03:00
|
|
|
export const IS_MAC = navigator.platform.toUpperCase().includes("MAC");
|
2024-07-17 16:46:45 +03:00
|
|
|
export const IS_ELECTRON = window.electron;
|
2020-03-18 19:40:21 +03:00
|
|
|
|
2023-02-13 14:39:16 +03:00
|
|
|
export function isOnlyCtrlOrCmdKeyEvent(ev: React.KeyboardEvent | KeyboardEvent): boolean {
|
2022-05-04 00:04:37 +03:00
|
|
|
if (IS_MAC) {
|
2017-12-01 13:30:49 +03:00
|
|
|
return ev.metaKey && !ev.altKey && !ev.ctrlKey && !ev.shiftKey;
|
|
|
|
} else {
|
|
|
|
return ev.ctrlKey && !ev.altKey && !ev.metaKey && !ev.shiftKey;
|
|
|
|
}
|
|
|
|
}
|