Aetae,
попытка уйти от зависимости ))) скорость 120 пикселей в секунду.
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
body,html{background:#FC9;height:100%}
div{height:100px;width:100px;background:#006400;position:relative;left:200px;top:200px}
</style>
<script>
window.onload = function() {
function move(t) {
for (var a in c)
if (c[a]) {
var d = b[a][0];
b[d] += (t - c[a])/1000 * b[a][1];
c[a] = t;
div.style[d] = (b[d]|0) + "px"
}
window.requestAnimationFrame(move)
}
var b = {
39: ["left", 120],
37: ["left", -120],
40: ["top", 120],
38: ["top", -120],
left: 200,
top: 200
},
c = {};
window.requestAnimationFrame(move);
var div = document.getElementById("show");
document.body.onkeydown = function(a) {
a = a || window.event;
a = a.keyCode;
a in b && (c[a] = performance.now());
};
document.body.onkeyup = function(a) {
a = a || window.event;
a = a.keyCode;
a in b && (c[a] = false);
}
};
</script>
</head>
<body>
<div id="show" ></div>
</body>
</html>