Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do you move with the arrow keys?
- Bookz4ever
-
15 posts
How do you move with the arrow keys?
How do you move with the arrow keys? Please help!

- AonymousGuy
-
1000+ posts
How do you move with the arrow keys?
It depends on the kind of movement you want, but, for movement where basically you can move a sprite up, down, left, and right:
- TheLogFather
-
1000+ posts
How do you move with the arrow keys?
@Nolieman1: I'd recommend against using “when key pressed” hat blocks for movement, usually.
Instead, use the “key pressed” sensor blocks (as in AonymousGuy's example script).
For an explanation of why (one reason, anyway - there are others, too), see this demo project:

http://scratch.mit.edu/projects/18453174
Instead, use the “key pressed” sensor blocks (as in AonymousGuy's example script).
For an explanation of why (one reason, anyway - there are others, too), see this demo project:

http://scratch.mit.edu/projects/18453174
Last edited by TheLogFather (March 17, 2014 22:05:45)
- acopper
-
2 posts
How do you move with the arrow keys?
I have a student who is trying to use the arrow keys to move her sprite (creating a maze). When she pushes the second arrow key (and any consecutive ones after using the first one), her sprite “jumps” to an entirely different place. The only things she has in there are when arrow key is pressed move 10 steps and point in direction degrees. Any ideas what is going on with her project?
- TheLogFather
-
1000+ posts
How do you move with the arrow keys?
My guess would be that the sprite costume is not centred. Consequently, when its rotation direction changes, it appears to offset by a large amount. I have a student who is trying to use the arrow keys to move her sprite (creating a maze). When she pushes the second arrow key (and any consecutive ones after using the first one), her sprite “jumps” to an entirely different place. The only things she has in there are when [up, down, left, right] arrow key is pressed move 10 steps and point in direction [90,-90,180,0] degrees. Any ideas what is going on with her project?
Go into the sprite's costume and click on the button to the top-right of the costume editor pane that has the cross in it (next to the flip buttons). That will show you where the costumes centre is located (and that is the point about which the costume rotates when you change direction). You can then move it to where you actually want it.
Hope that helps!
- acopper
-
2 posts
How do you move with the arrow keys?
TheLogFather - Thank you so much! I didn't think about having her check that. The costume was far from being centered. Thanks again for the help!!!
- Bookz4ever
-
15 posts
How do you move with the arrow keys?
Thank you all! To move with the arrow keys, follow AnouymusGuy's procedure! Thanks. 

- derpmeup
-
1000+ posts
How do you move with the arrow keys?
I'll give you a velocity engine:
First create these variables.

First create these variables.
And then make this script:
Hope that helped!

Last edited by derpmeup (April 27, 2014 20:54:30)
- levtey
-
100+ posts
How do you move with the arrow keys?
I think it's because the maze wall affects the sprite. Try lowering 10 to 2 or 4. I have a student who is trying to use the arrow keys to move her sprite (creating a maze). When she pushes the second arrow key (and any consecutive ones after using the first one), her sprite “jumps” to an entirely different place. The only things she has in there are when arrow key is pressed move 10 steps and point in direction degrees. Any ideas what is going on with her project?
- polemon
-
3 posts
How do you move with the arrow keys?
Last edited by polemon (April 28, 2014 11:03:06)
- Zacshap21
-
100+ posts
How do you move with the arrow keys?
Make sure that her cosume isn't really big. There might be a lot of whie in it that she can't see that needs to be erased. I have a student who is trying to use the arrow keys to move her sprite (creating a maze). When she pushes the second arrow key (and any consecutive ones after using the first one), her sprite “jumps” to an entirely different place. The only things she has in there are when arrow key is pressed move 10 steps and point in direction degrees. Any ideas what is going on with her project?
- yurt3
-
10 posts
How do you move with the arrow keys?
then add other arrow keys. Done!
Last edited by yurt3 (May 25, 2014 16:11:26)
- vpmitc
-
2 posts
How do you move with the arrow keys?
This way of controlling the sprite works great on Windows, but in UBUNTU if you press two keys at the same time, the sprite keeps moving out of control till it hits the border. It looks like a bug that happens only on UBUNTU or LINUX.
Is there a fix?
Is there a fix?
- lilhawkeye05
-
15 posts
How do you move with the arrow keys?
Use the when ___ key pressed block 4 times.
Put zero degrees for up, 180 degrees for down, 90 degrees for right and -90 degrees for left.
Snap the move 10 steps block onto each script an then you can add details to make a game! (:
Put zero degrees for up, 180 degrees for down, 90 degrees for right and -90 degrees for left.
Snap the move 10 steps block onto each script an then you can add details to make a game! (:
Last edited by lilhawkeye05 (Oct. 4, 2014 21:57:17)
- RPFluffy
-
1000+ posts
How do you move with the arrow keys?
uhhh, no!
Do this instead:
Don't do this as one key will dominate others:
Last edited by RPFluffy (Oct. 5, 2014 00:14:54)
- TRIZO12
-
33 posts
How do you move with the arrow keys?
http://scratch.mit.edu/projects/28662862
This is a Project with a simple moving engine.
You're welcome to Remix!
This is a Project with a simple moving engine.
You're welcome to Remix!
- Discussion Forums
- » Help with Scripts
-
» How do you move with the arrow keys?