mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-16 13:41:53 +03:00
87 lines
2 KiB
JavaScript
87 lines
2 KiB
JavaScript
/*
|
|
Copyright 2016 OpenMarket Ltd
|
|
Copyright 2017 New Vector Ltd
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
|
|
|
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.
|
|
*/
|
|
|
|
export const Key = {
|
|
HOME: "Home",
|
|
END: "End",
|
|
PAGE_UP: "PageUp",
|
|
PAGE_DOWN: "PageDown",
|
|
BACKSPACE: "Backspace",
|
|
ARROW_UP: "ArrowUp",
|
|
ARROW_DOWN: "ArrowDown",
|
|
ARROW_LEFT: "ArrowLeft",
|
|
ARROW_RIGHT: "ArrowRight",
|
|
TAB: "Tab",
|
|
ESCAPE: "Escape",
|
|
ENTER: "Enter",
|
|
ALT: "Alt",
|
|
CONTROL: "Control",
|
|
META: "Meta",
|
|
SHIFT: "Shift",
|
|
CONTEXT_MENU: "ContextMenu",
|
|
|
|
COMMA: ",",
|
|
LESS_THAN: "<",
|
|
GREATER_THAN: ">",
|
|
BACKTICK: "`",
|
|
SPACE: " ",
|
|
A: "a",
|
|
B: "b",
|
|
C: "c",
|
|
D: "d",
|
|
E: "e",
|
|
F: "f",
|
|
G: "g",
|
|
H: "h",
|
|
I: "i",
|
|
J: "j",
|
|
K: "k",
|
|
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",
|
|
Y: "y",
|
|
Z: "z",
|
|
};
|
|
|
|
export function isOnlyCtrlOrCmdKeyEvent(ev) {
|
|
const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
if (isMac) {
|
|
return ev.metaKey && !ev.altKey && !ev.ctrlKey && !ev.shiftKey;
|
|
} else {
|
|
return ev.ctrlKey && !ev.altKey && !ev.metaKey && !ev.shiftKey;
|
|
}
|
|
}
|
|
|
|
export function isOnlyCtrlOrCmdIgnoreShiftKeyEvent(ev) {
|
|
const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
if (isMac) {
|
|
return ev.metaKey && !ev.altKey && !ev.ctrlKey;
|
|
} else {
|
|
return ev.ctrlKey && !ev.altKey && !ev.metaKey;
|
|
}
|
|
}
|