2020-03-09 15:06:35 +02:00
|
|
|
export const isDarwin = /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);
|
|
|
|
|
2020-01-09 02:00:59 +04:00
|
|
|
export const KEYS = {
|
|
|
|
ARROW_LEFT: "ArrowLeft",
|
|
|
|
ARROW_RIGHT: "ArrowRight",
|
|
|
|
ARROW_DOWN: "ArrowDown",
|
|
|
|
ARROW_UP: "ArrowUp",
|
|
|
|
ENTER: "Enter",
|
|
|
|
ESCAPE: "Escape",
|
|
|
|
DELETE: "Delete",
|
2020-01-19 13:21:33 -08:00
|
|
|
BACKSPACE: "Backspace",
|
2020-03-09 15:06:35 +02:00
|
|
|
CTRL_OR_CMD: isDarwin ? "metaKey" : "ctrlKey",
|
2020-01-25 19:37:58 -03:00
|
|
|
TAB: "Tab",
|
2020-01-30 17:08:59 -03:00
|
|
|
SPACE: " ",
|
2020-03-09 15:06:35 +02:00
|
|
|
} as const;
|
2020-01-09 02:00:59 +04:00
|
|
|
|
|
|
|
export function isArrowKey(keyCode: string) {
|
|
|
|
return (
|
|
|
|
keyCode === KEYS.ARROW_LEFT ||
|
|
|
|
keyCode === KEYS.ARROW_RIGHT ||
|
|
|
|
keyCode === KEYS.ARROW_DOWN ||
|
|
|
|
keyCode === KEYS.ARROW_UP
|
|
|
|
);
|
|
|
|
}
|