const input = document.getElementsByTagName('input')[0]
let timer = null
input.addEventListener('keyup', () => {
if (timer) {
clearTimeout(timer)
}
timer = setTimeout(() => {
console.log(input.value)
timer = null
}, 500)
})
<input type="text" id="input">