, - .
If you look at the repetition interval of the operating system keyboard, it should be about 35 milliseconds - test it here .
In addition, you animate every 10 ms, not counting the time required to run all the animation functions, etc. So why not simplify the animation and not worry about time intervals ( try this demo ):
var block = $('.block'),
leftPos;
$(document).keydown(function (e) {
leftPos = block.position().left;
leftPos += (e.which == 37) ? -5 : 0;
leftPos += (e.which == 39) ? 5 : 0;
block.css('left', leftPos);
});
source
share