i'm trying to make tag input and when user type ',' character i wan't to add entry to input
i use for it like that function on onKeyDown
inputKeydown = e => {
const val = e.target.value;
var patt = /^[0-9]*$/;
if (e.key === "Enter" || e.which === 188 && val) {
let a = this.state.zips.includes(val);
if (
this.state.tags.find(
tag => tag.value.toLowerCase() === val.toLowerCase()
)
) {
return;
}
if (val.length != 5) {
return;
}
this.setState({ tags: [...this.state.tags, { match: a, value: val }] });
this.tagInput.value = null;
} else if (e.key === "Backspace" && !val) {
this.removeTag(this.state.tags.length - 1);
}
};
here is if user press to enter entry goes to this.state.tags array here i wan't to do if user type ',' will be same action.
i used for that
e.which === 188
everything works well but this add to input ',' character too. i don't wan't to show ',' character in input what i need to do ?