24 lines
524 B
TypeScript
24 lines
524 B
TypeScript
|
export const KEYS = {
|
||
|
ARROW_LEFT: "ArrowLeft",
|
||
|
ARROW_RIGHT: "ArrowRight",
|
||
|
ARROW_DOWN: "ArrowDown",
|
||
|
ARROW_UP: "ArrowUp",
|
||
|
ENTER: "Enter",
|
||
|
ESCAPE: "Escape",
|
||
|
DELETE: "Delete",
|
||
|
BACKSPACE: "Backspace"
|
||
|
};
|
||
|
|
||
|
export const META_KEY = /Mac|iPod|iPhone|iPad/.test(window.navigator.platform)
|
||
|
? "metaKey"
|
||
|
: "ctrlKey";
|
||
|
|
||
|
export function isArrowKey(keyCode: string) {
|
||
|
return (
|
||
|
keyCode === KEYS.ARROW_LEFT ||
|
||
|
keyCode === KEYS.ARROW_RIGHT ||
|
||
|
keyCode === KEYS.ARROW_DOWN ||
|
||
|
keyCode === KEYS.ARROW_UP
|
||
|
);
|
||
|
}
|