Mario doesn't move right, up or down


Mario moves left but not in any other direction.

My code is below. Does the problem have anything to do with me using a MacBook Pro.

$(document).ready(function() {
    $(document).keydown(function(key) {
        switch(parseInt(key.which,10)) {
			// Left arrow key pressed
			case 37:
				$('img').animate({left: "-=10px"}, 'fast');
			// Up Arrow Pressed
			case 38:
				// Put our code here
			$('img').animate({up: "-=10px"}, 'fast');                   break;
			// Right Arrow Pressed
			case 39:
				// Put our code here
			$('img').animate({right: "+=10px"}, 'fast');
			// Down Arrow Pressed
			case 40:
				// Put our code here
			$('img').animate({down: "+=10px"}, 'fast');


Hi Nigelleeinvicta,

You need to animate Mario in the top and left directions, and control right, left, up, and down, with either -= or += the number of pixels :)

& no, your using a MBP shouldn't be affecting anything.


I thought the code I have there is correct and complete. Could you point out what's wrong / missing.



@nigelleeinvicta I already told you what's wrong with your code, see my post above.
Or do you want me to be more specific?


you have to write use the top and left keywords only. read the lesson more carefully. I had the same issue.

basically it says that if you type: ("item").animate({top: '+=10px},100) this particular code will move the image down if you want to move the image to the right then you use left: '+=10px'
hopefully this made some sense.


I have the same problem: the img move only to the left.
If you know how to move image to the different direction would you please show it in the code.