Exercise 8 not working for me, why?

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

not work for me..why?

8. The .keydown() Event

Hi Nico,

Don't use the bottom and right keywords. You need to control the image's position by adding or subtracting 10px from left or top :slight_smile:


.......what is missing?


@chipsolver75782 Nothing, but you need to use left and right for all directions, you can't use right and bottom.


you can show me the code?


@chipsolver75782 No, that's not allowed. Take your best shot at following my instructions, and if you're still having trouble, post your code and the error message you're getting.


the error look me is "Please press the required key down on [object Object]."


@chipsolver75782 Click on the image, then press at least one of your arrow keys. Then wait two seconds and return to the editor.


ok work..sorry :confused:


@chipsolver75782 No worries, glad it's working now :slight_smile:


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