how to make arrow key movement in scratch code example
Example 1: how to make scratch move with arrow keys
up
when flag clicked(events)
forever(events)
if then(events)
key up arrow pressed(sensing)
drag key up arrow pressed into if then
chang y by 5(motion)
down
when flag clicked(events)
forever(events)
if then(events)
key down arrow pressed(sensing)
drag key down arrow pressed into if then
chang y by -5(motion)
right
when flag clicked(events)
forever(events)
if then(events)
key right arrow pressed(sensing)
drag key right arrow pressed into if then
chang x by 5(motion)
left
when flag clicked(events)
forever(events)
if then(events)
key left arrow pressed(sensing)
drag key left arrow pressed into if then
chang x by -5(motion)
Example 2: how to make arrow key movement in scratch
To make your character move up:
(events) when flag clicked
(control) forever
(control) if then
(sensing) key up arrow pressed
drag "key up arrow pressed" block into if then
(motion)change y by 5
To make your character move down down :
(events) when flag clicked
(control) forever
(control) if then
(sensing) key down arrow pressed
drag "key down arrow pressed" block into if then
(motion)change y by -5
To make your character move right:
(events) when flag clicked
(control) forever
(control) if then
(sensing) key right arrow pressed
drag "key right arrow pressed" block into if then
(motion)change x by 5
To make your character move left:
(events) when flag clicked
(control) forever
(control) if then
(sensing) key left arrow pressed
drag "key left arrow pressed" block into if then
(motion)change x by -5