Edit in JSFiddle

//setup before functions
var typingTimer; //timer identifier
var doneTypingInterval = 5000; //time in ms (5 seconds)

//on keyup, start the countdown
$('#myInput').keyup(function() {
    clearTimeout(typingTimer);
    if ($('#myInput').val()) {
        typingTimer = setTimeout(doneTyping, doneTypingInterval);
    }
});

//user is "finished typing," do something
function doneTyping() {
    //do something
    alert('Hello')
}
<input type="text" id="myInput">
body {
    min-height: 200px;
    background: #eaeaea;
}