var inputElm_$name = document.getElementById("$name");
tagify = new Tagify (inputElm_$name);

tagify.on('keydown', onTagifyKeyDown)

function onTagifyKeyDown(e){
if( e.key == 'Enter' || e.key == ' ' &&         // "enter" key pressed
!tagify.state.inputText &&  // assuming user is not in the middle oy adding a tag
!tagify.state.editing       // user not editing a tag
){
setTimeout(() => formElm.submit())  // put some buffer to make sure tagify has done with whatever, to be on the safe-side
}

}

inputElm_$name.addEventListener('change', onChange)

function onChange(e){
// outputs a String
console.log(e.target.value)
}