JSFiddle - React, Tailwind, and code Playground

by Eduardo GarcĂ­a Sanz

HTML

<div ng-controller="Main">
    <input ng-model="input" ng-keydown="startTyping()"  ng-keyup="stopTyping()"/>
</div>

JavaScript

var app = angular.module('app', []);

app.controller('Main', function ($scope) {
    
    var delays = [];
    
    var lookup = function() {
        
        console.log($scope.input);
    };

    $scope.startTyping = function() {
        
        console.log(delays);
        angular.forEach(delays, function(delay) {
        
            clearTimeout(delay);
        });
        delays = [];
    };

    $scope.stopTyping = function() {
        
        delays.push(setTimeout(lookup, 1000));
    };
});