Discuss Scratch

BB1000000000
Scratcher
34 posts

Question about Key [ v] Pressed: why does the dropdown allow reporters?

In Scratch 3.0, the
key [ v] pressed?
block has a dropdown that, for some reason, allows reporters and Booleans to fit in it, creating a scenario like this possible:
key (item (random v) of [key-names v]) pressed?
Dropping variables in the dropdown that store key names (use this code as an example):
set [key name v] to [desired key name]
say <key (key name) pressed?>
allow you to sense whether the Enter key and miscellaneous symbols on the keyboard are pressed.
(by the way, the
when [ v] key pressed
block doesn't allow this, and this isn't possible in earlier versions of Scratch.
I am just wondering why this is allowed.
apple502j
Scratcher
1000+ posts

Question about Key [ v] Pressed: why does the dropdown allow reporters?

I think because it's now a feature? (also makey makey extension's hat blocks allow reporters too!)
CatsUnited
Scratcher
1000+ posts

Question about Key [ v] Pressed: why does the dropdown allow reporters?

apple502j wrote:

I think because it's now a feature? (also makey makey extension's hat blocks allow reporters too!)
I'm glad it is a feature though; it makes things like custom keybinds for games possible without relying on modifying the project's JSON file.
BB1000000000
Scratcher
34 posts

Question about Key [ v] Pressed: why does the dropdown allow reporters?

bump
minor-edit
Scratcher
500+ posts

Question about Key [ v] Pressed: why does the dropdown allow reporters?

It lets the number of options in the menu be kept a reasonable length while also supporting the extra symbols and enter (and possibly backspace in the future) and keeps code lightweight to detect an alphabet of keys.

set [muh keys v] to [abcdefghijkmnopqrsuvwxyz01253sir...&$%#]
set [index v] to [1]
repeat (length of (muh keys))
set [my key v] to (letter (index) of (muh keys))
create clone of [myself v]
change [index v] by (1)
end
when I start as a clone
forever
wait until <key (my key) pressed?>
wait until <not <key (my key) pressed?>>
do important key related stuff :: grey
end
And older projects that relied on a reporter in the input for key detection remain salvageable.

Powered by DjangoBB