Edit in JSFiddle

var timeout = null
$('input').on('keyup', function() {
    var text = this.value
    clearTimeout(timeout)
    timeout = setTimeout(function() {
        // Do AJAX shit here            
        console.log(text)
    }, 500)
})
<input>