-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 141: make shortcuts customizable.
- Loading branch information
Showing
13 changed files
with
327 additions
and
162 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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Get the pressed keys as a string, eg 'meta-c', 'shift-a'. | ||
* | ||
* Note that there _must_ be a "regular" key pressed as well. | ||
* If only meta/alt/ctl/shift are pressed, returns null. | ||
*/ | ||
function get_pressed_keys_as_string(event) { | ||
const keys = []; | ||
|
||
// Check for modifier 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'); | ||
|
||
// Map special keys to names if needed | ||
const keyMap = { | ||
' ': 'space' | ||
}; | ||
|
||
if (event.key == null) { | ||
// window.alert("no key for event?"); | ||
return null; | ||
} | ||
|
||
const actual_key = keyMap[event.key] || event.key.toLowerCase(); | ||
if (['shift', 'ctrl', 'alt', 'meta'].includes(actual_key)) | ||
return null | ||
|
||
keys.push(actual_key); | ||
const ret = keys.join('+'); | ||
// window.alert(`got hotkey = ${ret}`); | ||
return ret; | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.