You can use this code :
$('input').keyup(function(e){
var timer = $(this).data('__timer');
clearTimeout(timer);
$(this).data('__timer', setTimeout(function(e){
//Your ajax here.
console.log(e)
}.bind(this, e), 500));
})