Skip to content

Commit

Permalink
option key crosshair
Browse files Browse the repository at this point in the history
  • Loading branch information
lxieyang committed Nov 19, 2020
1 parent 5c10112 commit 4eb774d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pages/Content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ bboxAnchor.style.left = '0px';
bboxAnchor.style.width = `0px`;
bboxAnchor.style.height = `0px`;

let mouseIsDown = false;
let hotKeyIsDown = false,
mouseIsDown = false;
let startingX: number | undefined = undefined,
startingY: number | undefined = undefined;

Expand Down Expand Up @@ -98,5 +99,17 @@ window.addEventListener('keydown', (event) => {
startingY = undefined;
document.body.classList.remove('no-select');
resetBBoxAnchor();
} else if (event.altKey) {
hotKeyIsDown = true;
document.body.classList.add('no-select');
}
});

window.addEventListener('keyup', (event) => {
if (hotKeyIsDown && !event.altKey) {
hotKeyIsDown = false;
if (!mouseIsDown) {
document.body.classList.remove('no-select');
}
}
});

0 comments on commit 4eb774d

Please sign in to comment.