-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: custom shortcut with mouse buttons #91;
- Loading branch information
1 parent
c0e411f
commit 21216d8
Showing
5 changed files
with
59 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
export default function parseKey(event: KeyboardEvent) { | ||
export default function parseKey(event: KeyboardEvent | MouseEvent) { | ||
const keys = []; | ||
if (event.ctrlKey) keys.push("Ctrl"); | ||
if (event.shiftKey) keys.push("Shift"); | ||
if (event.altKey) keys.push("Alt"); | ||
if (event.metaKey) keys.push("Meta"); | ||
let key = event.key; | ||
if (key === " ") key = "Space"; | ||
keys.push(key); | ||
if (event instanceof KeyboardEvent) { | ||
let key = event.key; | ||
if (key === " ") key = "Space"; | ||
keys.push(key); | ||
} | ||
if (event instanceof MouseEvent) { | ||
let key = "M" + event.button; | ||
keys.push(key); | ||
} | ||
return keys.join("+"); | ||
} |