Hi,
I cannot move div by A, W, D, S keys: http://jsfiddle.net/8Observer8/mHAHz/128/
Thank you!
$('square')
instead of
$('.square')
Gotta match the class, not a
<square>
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!