//sample solution to script.js
$(document).ready(function() {
$(document).keydown(function(key) {
switch(parseInt(key.which,10)) {
case 65://left
$('img').animate({left: "-=10px"}, 'fast');
break;
case 83://down
$('img').animate({top: "+=10px"}, 'fast');
break;
case 87://up
$('img').animate({top: "-=10px"}, 'fast');
break;
case 68:
$('img').animate({left: "+=10px"}, 'fast');
break;
default:
break;
}
});
});
No comments:
Post a Comment