Conversation
|
Thought: what about having it be an attribute on the input? <input type="tags" data-separator=":" value="foo:bar:baz"> |
|
Yup. Much better. Let me rework it. |
a138e21 to
8f56b98
Compare
`data-separator` attribute on a wrapped input element can be used to specify tags separator We use `KeyboardEvent.key` to detect separator, if browser does not support it (Safari) we fall back to KeyboardEvent.keyIdentifier see: http://caniuse.com/#search=KeyboardEvent.key
8f56b98 to
7405d0e
Compare
|
Some fixes:
|
|
How can one specify multible seperators? E.g. |
| base.input.addEventListener('keydown', e => { | ||
| let el = base.input, | ||
| key = e.keyCode || e.which, | ||
| char = charFromKeyboardEvent(e), |
There was a problem hiding this comment.
hmm - I think we could just use String.fromCharCode(key) here, couldn't we?
There was a problem hiding this comment.
I wish. If only Safari behaved ;-)
There was a problem hiding this comment.
but its using keyCode, not charCode. I thought that worked? 😥
There was a problem hiding this comment.
Yeah - keyCode works in most browsers on keypress event. But on keydown a different story.
Mobile (iOS) Safari tends to have strange values in keyCode on keydown - for example , (comma) generates 188 which corresponds to '¼'. I am sure that there is some logic behind it, and I am sure that we are up for yet another how to translate key events to key value standard at some point, but for now we are still in the waving hands and magic land.
|
@luckydonald by pasting |
|
@luckydonald - |
|
Ah now I see what was being asked haha. |
|
Detecting keys is tricky, not all documented properties are set on all events. For example |
|
🙏 |
|
@0xc00010ff check @pirxpilot 's fork |
it's still comma by default but you can pass
{ separator: ' ' }or{ separator: ':' }as an option argument when creatingtags-input