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",
|
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: ",",
|
2019-10-09 18:59:11 +00:00
|
|
|
LESS_THAN: "<",
|
|
|
|
GREATER_THAN: ">",
|
|
|
|
BACKTICK: "`",
|
|
|
|
SPACE: " ",
|
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
|
|
|
|
2017-12-01 10:44:00 +00:00
|
|
|
export function isOnlyCtrlOrCmdKeyEvent(ev) {
|
2017-12-01 10:30:49 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2018-01-03 11:39:15 +00:00
|
|
|
|
2018-01-04 12:06:13 +00:00
|
|
|
export function isOnlyCtrlOrCmdIgnoreShiftKeyEvent(ev) {
|
2018-01-03 11:39:15 +00:00
|
|
|
const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
|
|
if (isMac) {
|
2018-01-04 12:06:13 +00:00
|
|
|
return ev.metaKey && !ev.altKey && !ev.ctrlKey;
|
2018-01-03 11:39:15 +00:00
|
|
|
} else {
|
2018-01-04 12:06:13 +00:00
|
|
|
return ev.ctrlKey && !ev.altKey && !ev.metaKey;
|
2018-01-03 11:39:15 +00:00
|
|
|
}
|
|
|
|
}
|