const data = {msg:''}
const input = document.getElementById('input')
const span = document.getElementById('span')
Object.defineProperty(data, 'msg', {
configurable:true,
enumerable:true,
get () {
return input.value
},
set (newVal) {
input.value = newVal;
span.innerText = newVal;
}
})
input.onkeyup = function (e) {
data.msg = e.target.value;
}
<input type="" id='input'>
<span id="span"></span>