-
-
Notifications
You must be signed in to change notification settings - Fork 210
Support using event.key or .code instead of deprecated keyCode #271
Comments
Good point! 👍 I'm not sure about using
If you want to give it a try, please feel free to submit a PR! 😎 |
From MDN:
TL;DR: |
I'll publish this as v1.1.0 and v2.0.0-beta.2 tomorrow. 😴 |
@leMaik Did you publish the v2.0.0-beta.2? I'm not seeing it in the releases. |
@akrz Whoops... Well, here they are: v1.1.0 and v2.0.0-beta.2 |
TL;DR: Would like to use e.g.
newChipKeys={['Enter', 'Tab']}
instead of or in addition tonewChipKeyCodes={[13, 9]}
I am using ChipInput for an email input field.
I noticed some strange behavior, having set
newChipKeyCodes
to[9, 13, 187, 188]
in order to trigger on Tab, Enter, SemiColon and Comma (on norwegian keyboards).When I was entering an email with a plus sign in it, that also triggered. Did some digging, and turns out keyCodes are different depending on keyboard language, so e.g. SemiColon is keyCode 187 for norwegian layout, but code 186 for US layouts; in US layouts, 187 is the code for plus or equals.
According to MDN, keyCodes are deprecated, and the replacement is to use either
KeyboardEvent.code
orKeyboardEvent.key
.Not sure which one of
key
andcode
would be most fitting here, but either one of them is probably better thankeyCode
.The text was updated successfully, but these errors were encountered: