-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Fix #183: Add separate dictionary of keys that cmd hides the keyup …
…events for
- Loading branch information
Showing
4 changed files
with
40 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Dictionary of keys that, when pressed down with the cmd key, never trigger a keyup | ||
* event in the browser | ||
*/ | ||
const KeysWithKeyupHiddenByCmd = { | ||
Enter: true, | ||
Backspace: true, | ||
ArrowRight: true, | ||
ArrowLeft: true, | ||
ArrowUp: true, | ||
ArrowDown: true, | ||
/** | ||
* Caps lock is a strange case where it not only does not have a key press event, | ||
* but it's keyup event is triggered when caps lock is toggled off | ||
*/ | ||
CapsLock: true, | ||
}; | ||
|
||
for(let i = 1; i < 13; i++) { | ||
KeysWithKeyupHiddenByCmd[`F${i}`] = true; | ||
} | ||
|
||
export default KeysWithKeyupHiddenByCmd; |
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,14 @@ | ||
import KeysWithKeyupHiddenByCmd from '../../const/KeysWithKeyupHiddenByCmd'; | ||
import hasKey from '../../utils/object/hasKey'; | ||
|
||
/** | ||
* Whether the specified key, when pressed down with the cmd key, never triggers a keyup | ||
* event in the browser | ||
* @param {NormalizedKeyName} keyName Name of the key | ||
* @returns {Boolean} Whether the key has its keyup event hidden by cmd | ||
*/ | ||
function keyupIsHiddenByCmd(keyName) { | ||
return keyName.length === 1 || hasKey(KeysWithKeyupHiddenByCmd, keyName); | ||
} | ||
|
||
export default keyupIsHiddenByCmd; |
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