I cannot move div by A, W, D, S keys: http://jsfiddle.net/8Observer8/mHAHz/128/
1) You don't match the right keys. It might be browser specific, not sure with jQuery, but mine are different than what you input.
2) You do
Gotta match the class, not a
3) You need to add a 'position' attribute to the square's css properties.
Try this: http://jsfiddle.net/mHAHz/130/
Thank you very much! How to move continuously (very fast and continuously)?
What do you mean continuously? back and forth? Use window.setInterval to find when it gets to either side and have it fade the opposite way.
I want to move div how a "small car".
I think this div needs to be moved like Link in Legend of Zelda. So instead, he probably needs to listen for repeated key events as the key is held down (the key keeps making new events while it is held down?).
Probably the script is slow because for each key it's findgin .square again and again. It should be faster if .square is found once and saved into a variable. Before document.onkeydown event listener.
Thank you very much! This is the example from your link: http://jsfiddle.net/bDMnX/7/ I wanted to make this. Thanks!
This topic is now closed. New replies are no longer allowed.