-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d529496
commit b967046
Showing
17 changed files
with
336 additions
and
247 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { isArray } from 'min-dash'; | ||
|
||
/** | ||
* Returns true if event was triggered with any modifier | ||
* @param {KeyboardEvent} event | ||
*/ | ||
export function hasModifier(event) { | ||
return (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey); | ||
} | ||
|
||
/** | ||
* @param {KeyboardEvent} event | ||
*/ | ||
export function isCmd(event) { | ||
|
||
// ensure we don't react to AltGr | ||
// (mapped to CTRL + ALT) | ||
if (event.altKey) { | ||
return false; | ||
} | ||
|
||
return event.ctrlKey || event.metaKey; | ||
} | ||
|
||
/** | ||
* Checks if key pressed is one of provided keys. | ||
* | ||
* @param {String|String[]} keys | ||
* @param {KeyboardEvent} event | ||
*/ | ||
export function isKey(keys, event) { | ||
keys = isArray(keys) ? keys : [ keys ]; | ||
|
||
return keys.indexOf(event.key) > -1; | ||
} | ||
|
||
/** | ||
* @param {KeyboardEvent} event | ||
*/ | ||
export function isShift(event) { | ||
return event.shiftKey; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.