Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » Question about Key [ v] Pressed: why does the dropdown allow reporters?
- BB1000000000
-
34 posts
Question about Key [ v] Pressed: why does the dropdown allow reporters?
In Scratch 3.0, the
(by the way, the
I am just wondering why this is allowed.
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]allow you to sense whether the Enter key and miscellaneous symbols on the keyboard are pressed.
say <key (key name) pressed?>
(by the way, the
when [ v] key pressedblock doesn't allow this, and this isn't possible in earlier versions of Scratch.
I am just wondering why this is allowed.
- apple502j
-
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
-
1000+ posts
Question about Key [ v] Pressed: why does the dropdown allow reporters?
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. I think because it's now a feature? (also makey makey extension's hat blocks allow reporters too!)
- BB1000000000
-
34 posts
Question about Key [ v] Pressed: why does the dropdown allow reporters?
bump
- minor-edit
-
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 cloneAnd older projects that relied on a reporter in the input for key detection remain salvageable.
forever
wait until <key (my key) pressed?>
wait until <not <key (my key) pressed?>>
do important key related stuff :: grey
end
- Discussion Forums
- » Questions about Scratch
-
» Question about Key [ v] Pressed: why does the dropdown allow reporters?