2016-04-05 12:14:11 +00:00
|
|
|
/*
|
|
|
|
Copyright 2016 OpenMarket Ltd
|
2017-12-01 10:30:49 +00:00
|
|
|
Copyright 2017 New Vector Ltd
|
2019-12-16 17:14:03 +00:00
|
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
2016-04-05 12:14:11 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
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",
|
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");
|
2020-03-18 16:40:21 +00:00
|
|
|
|
2017-12-01 10:44:00 +00:00
|
|
|
export function isOnlyCtrlOrCmdKeyEvent(ev) {
|
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;
|
|
|
|
}
|
|
|
|
}
|