-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix nonprintable keys #199
Conversation
@@ -1,27 +0,0 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐥 Remove separate file previously used to record keys without keypress events - this is now just the list of non-printable keys.
@@ -0,0 +1,10 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐥 New dictionary of non-printable keys, that takes its values from the same list that the React normalization algorithm uses.
@@ -1,13 +0,0 @@ | |||
import SpecialKeysDictionary from '../../const/SpecialKeysDictionary'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐥 Move the list of "special" keys, to be referred to as "non-printable"
return isSpecialKey(keyName) || String.fromCharCode(keyName.charCodeAt(0)) === keyName; | ||
return isNonPrintableKeyName(keyName) || | ||
String.fromCharCode(keyName.charCodeAt(0)) === keyName || | ||
Configuration.option('customKeyCodes')[keyName]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅🐛Fix this line - incorrect way of accepting custom keys (it's a map of key codes to key names and this lookup will always fail).
@@ -28,50 +29,6 @@ const normalizeKey = { | |||
MozPrintableKey: 'Unidentified', | |||
}; | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐥☂️Abstract React's list of non-printable keys into a separate file, so it can be re-used by react-hotkeys
.
Context
react-hotkeys
uses a whitelist of accepted keynames in order to fail loudly if a user of the library enters an invalid key name. This list is currently incomplete, resulting in #198.This pull request
Takes the lead from the way that
react
itself handles keys, and consolidates all of the follow features into a single list:react-hotkeys
for global hotkeys that occur outside the React application)keypress
event, or whether it should be simulated (all non-printable keys do not have akeypress
event)react-hotkeys
may have made a mistake in defining their key sequence