Oops, try again. Make sure to press 'left', 'up', 'right', or 'down' to make your character move!


#1

This code works , but the platform says 'Oops, try again. Make sure to press 'left', 'up', 'right', or 'down' to make your character move!' . why ?


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


#2

When you get to the full preview, first click inside the window, then use the arrow keys to move right, then down.


#3

Thank you. you're absolutely right


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.