Código:
function moveObj(name, Xpix, Ypix) { obj = document.getElementById(name); px = parseInt(obj.style.left) + Xpix; py = parseInt(obj.style.top) + Ypix; obj.style.left = px; obj.style.top = py; } function ProcessKeypress(e) { var myObj = "saucer"; var moveBy = 10; if(e.keyCode) keycode=e.keyCode; else keycode=e.which; ch=String.fromCharCode(keycode); if(ch=='a') moveObj(myObj, -moveBy, 0); else if(ch=='s') moveObj(myObj, moveBy, 0); else if(ch=='w') moveObj(myObj, 0, -moveBy); else if(ch=='z') moveObj(myObj, 0, moveBy); }