Triggering callback after user stops typing jQuery

The snippet below triggers a callback when user stops typing on the input field. The process gets repeated everytime. This is a useful piece of snippet which can be used to trigger a custom callback function such as auto save or spelling checker etc.

JQUERY
12345678910

var x_timer;
$("#input-box").keyup(function (e){
    clearTimeout(x_timer);
    var user_name = $(this).val();
    x_timer = setTimeout(function(){
       // callback_function();
       console.log("user stopped");
    }, 1000);
});
You should see a text on your js console “user stopped” everytime you stop typing.