2016-04-05 12:14:11 +00:00
|
|
|
/*
|
2024-09-09 13:57:16 +00:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2019-12-16 17:14:03 +00:00
|
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
2024-09-09 13:57:16 +00:00
|
|
|
Copyright 2017 New Vector Ltd
|
|
|
|
Copyright 2016 OpenMarket Ltd
|
2016-04-05 12:14:11 +00:00
|
|
|
|
2024-09-09 13:57:16 +00: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 12:14:11 +00:00
|
|
|
*/
|
|
|
|
|
2023-02-13 11:39:16 +00:00
|
|
|
import React from "react";
|
|
|
|
|
2019-09-30 15:04:06 +00:00
|
|
|
export const Key = {
|
|
|
|
HOME: "Home",
|
2019-10-09 18:59:11 +00:00
|
|
|
END: "End",
|
2019-09-30 15:04:06 +00:00
|
|
|
PAGE_UP: "PageUp",
|
|
|
|
PAGE_DOWN: "PageDown",
|
2019-10-04 10:47:33 +00:00
|
|
|
BACKSPACE: "Backspace",
|
2020-03-26 07:37:46 +00:00
|
|
|
DELETE: "Delete",
|
2019-10-09 18:59:11 +00:00
|
|
|
ARROW_UP: "ArrowUp",
|
|
|
|
ARROW_DOWN: "ArrowDown",
|
2019-10-17 14:53:39 +00:00
|
|
|
ARROW_LEFT: "ArrowLeft",
|
|
|
|
ARROW_RIGHT: "ArrowRight",
|
2024-07-17 13:46:45 +00:00
|
|
|
F6: "F6",
|
2019-10-09 18:59:11 +00:00
|
|
|
TAB: "Tab",
|
|
|
|
ESCAPE: "Escape",
|
2019-10-04 10:47:33 +00:00
|
|
|
ENTER: "Enter",
|
2019-10-09 18:59:11 +00:00
|
|
|
ALT: "Alt",
|
|
|
|
CONTROL: "Control",
|
|
|
|
META: "Meta",
|
|
|
|
SHIFT: "Shift",
|
2019-12-02 10:01:08 +00:00
|
|
|
CONTEXT_MENU: "ContextMenu",
|
2019-09-30 15:04:06 +00:00
|
|
|
|
2019-12-16 17:14:03 +00:00
|
|
|
COMMA: ",",
|
2020-03-20 00:18:24 +00:00
|
|
|
PERIOD: ".",
|
2019-10-09 18:59:11 +00:00
|
|
|
LESS_THAN: "<",
|
|
|
|
GREATER_THAN: ">",
|
|
|
|
BACKTICK: "`",
|
|
|
|
SPACE: " ",
|
2020-03-18 16:40:21 +00:00
|
|
|
SLASH: "/",
|
2020-04-11 17:57:59 +00:00
|
|
|
SQUARE_BRACKET_LEFT: "[",
|
|
|
|
SQUARE_BRACKET_RIGHT: "]",
|
2022-03-08 15:05:36 +00:00
|
|
|
SEMICOLON: ";",
|
2019-12-16 17:14:03 +00:00
|
|
|
A: "a",
|
2019-10-09 18:59:11 +00:00
|
|
|
B: "b",
|
2019-12-16 17:14:03 +00:00
|
|
|
C: "c",
|
|
|
|
D: "d",
|
|
|
|
E: "e",
|
|
|
|
F: "f",
|
|
|
|
G: "g",
|
|
|
|
H: "h",
|
2019-10-09 18:59:11 +00:00
|
|
|
I: "i",
|
2019-12-16 17:14:03 +00:00
|
|
|
J: "j",
|
2019-09-30 15:04:06 +00:00
|
|
|
K: "k",
|
2019-12-16 17:14:03 +00: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 18:59:11 +00:00
|
|
|
Y: "y",
|
|
|
|
Z: "z",
|
2016-04-05 12:14:11 +00:00
|
|
|
};
|
2017-12-01 10:30:49 +00:00
|
|
|
|
2022-05-03 21:04:37 +00:00
|
|
|
export const IS_MAC = navigator.platform.toUpperCase().includes("MAC");
|
2024-07-17 13:46:45 +00:00
|
|
|
export const IS_ELECTRON = window.electron;
|
2020-03-18 16:40:21 +00:00
|
|
|
|
2023-02-13 11:39:16 +00:00
|
|
|
export function isOnlyCtrlOrCmdKeyEvent(ev: React.KeyboardEvent | KeyboardEvent): boolean {
|
2022-05-03 21:04:37 +00:00
|
|
|
if (IS_MAC) {
|
2017-12-01 10:30:49 +00:00
|
|
|
return ev.metaKey && !ev.altKey && !ev.ctrlKey && !ev.shiftKey;
|
|
|
|
} else {
|
|
|
|
return ev.ctrlKey && !ev.altKey && !ev.metaKey && !ev.shiftKey;
|
|
|
|
}
|
|
|
|
}
|