Stop an Ajax call
<pre><code>    $(document).keydown(function(e){
        if (e.keyCode == 37) { 
            move("West");
            return false;
        }
        if (e.keyCode == 38) { 
            move("North");
            return false;
        }
        if (e.keyCode == 39) { 
            move("East");
            return false;
        }
        if (e.keyCode == 40) { 
            move("South");
            return false;
        }
    });

        function move(newDirection)
        {
            var direction = newDirection;

            $.ajax({
                type: "POST",
                url: "ajax/map.php",
                data: { direction: direction },
                success: function(data) {
                    $('#content').html(data);
                }
            });
        }
</code></pre>

<p>If I keep down the Left key a while too long, the call will keep coming and coming, and it (won't stop) What I am looking for is to make some delay, or simply just make one call when the key is pressed (or perhaps stop instantly when the key is released) But I'm not sure how. Any suggestions on solution?</p>
