Discuss Scratch
- k7e
-
Scratcher
1000+ posts
"Key Pressed" Sensor Reporter Block
Again, what if someone does “keys pressed = right arrow”. The project would not work at all for people who speak another language, because it would report “right arrow” in a different language, unless someone uses the translate block. There are currently no blocks that report values that need to be translated.
Last edited by k7e (April 23, 2023 11:15:01)
- kitty1000pranjalc
-
Scratcher
25 posts
"Key Pressed" Sensor Reporter Block
Try some hacksTry this ^define keyPressesInList_allRequired
set [i v] to (1)
repeat (length of [presses v])
if <not<key (item (i) of [presses v]) pressed?>>
set [yes v] to (0) // idk if key pressed accepts a reporter. Try it! Otherwise edit the json
stop [this script v] // if not ALL keys in the list are pressed, return 0
end
change [i v] by (1)
end
set [yes v] to (1) // all keys in list pressed, return 1define keyPressesInList_oneRequiredThe stop […] blocks are in there to prevent unnecessary looping, which will slow your project down. Make sure to use custom blocks like above because then stop this script will only stop the custom block. Also make sure to make the custom blocks run without screen refresh to speed up the looping.
set [i v] to (1)
repeat (length of [presses v])
if <key (item (i) of [presses v]) pressed?>
set [yes v] to (1)
stop [this script v] // if at least ONE of the keys is pressed, return 1
end
change [i v] by (1)
end
set [yes v] to (0) // no keys in the list are pressed, return 0
It works…
I agree.
- Scyth3d
-
Scratcher
500+ posts
"Key Pressed" Sensor Reporter Block
1 year bump… also support cuz it would make my life easier


