mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Extract app and keys (#276)
* Extract app component from entrypoint (index) - Use refs to refer to canvas and rough context - Remove ReactDOM double rendering * Extract keys and key related utils into their own module * Move everything back to entrypoint
This commit is contained in:
parent
36ce6a26e6
commit
299e7e9099
3 changed files with 39 additions and 32 deletions
23
src/keys.ts
Normal file
23
src/keys.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
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
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue