Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

jQuery Keydown Movement

I am trying to make the plane img go across the screen. I have attached my code below. What am I doing wrong? Do I need to incorporate a specific script plug-in?

http://codepen.io/meppley7/pen/pfkDw

2 Answers

Tom Mertz
Tom Mertz
15,254 Points

I just loaded up your codepen and I was able to get the image icon to move across the screen and go up, down, and back with wasd. Was that what you were trying to do?

James Barnett
James Barnett
39,199 Points

Your JQuery works fine, I'm not sure what you are seeing. I forked your pen, added in plane & background image instead of the local images that codepen was 404'ing on. I also changed the delay on .animate from 'fast' is is 200ms down to 1 to reduce the lag.

http://codepen.io/jamesbarnett/full/vhsJD