Discuss Scratch
- Cream_E_Cookie
-
1000+ posts
(keys pressed?) block
Support if:
it is a LAST key pressed (by millisecond)
it is a LAST key pressed (by millisecond)
- Cute_Boot-art
-
13 posts
(keys pressed?) block
Support if:
it is a LAST key pressed (by millisecond)
- TheMasterKing107
-
36 posts
(keys pressed?) block
(key pressed contains []::sensing)I support both of them.
(key pressed::sensing)
Last edited by TheMasterKing107 (Sept. 8, 2015 13:35:17)
- scratchinghead
-
1000+ posts
(keys pressed?) block
Support.
key pressed included [] :: sensing boolean
- Arthurtilly
-
1000+ posts
(keys pressed?) block
There is a boolean that does that, the I support!
It shouldn't be called key/s pressed? though, since a block can only report one value at one time.
Also, when no keys are pressed, does it change to “none” or something like that, or will it stay as the last one?
If it's the latter, there should be a block like this too:any key pressed? :: sensing boolean(that's supposed to be a boolean you can put into a if statement btw)
<key [ v] pressed?>block has an “any” option.
There are simple hacks in certain projects that let those keys be detected, but I agree it would be nice for them to be in the options. ALSO add Shift, Enter, Delete, Tab, Shift, and symbol support (period, comma, slash, etc.)
- julianandwill
-
500+ posts
(keys pressed?) block
This would act as an automatic list, as these are automatic variables:
(x position)
(y position)
(direction)
(costume #)
(backdrop name)
(size)
(backdrop #)
(volume)
(tempo)
(distance to [ v])
(answer)
(mouse x)
(mouse y)
(loudness)
(video [ v] on [ v])
(timer)
([ v] of [ v])
(current [ v])
(days since 2000)
(username)
Last edited by julianandwill (Sept. 21, 2015 23:35:42)
- 14Gkurzepa
-
5 posts
(keys pressed?) block
The idea of having a
Support!
Maybe other keys should also be added, such as Shift, etc. etc. However this could interfere with default OS commands such as sticky keys, so it could be a problem.
<key pressed>would be very useful. This could allow you to make search engines without having to make a keyboard or adding an ‘if this key pressed then add this key to the list’ about a trillion times.
Support!
Maybe other keys should also be added, such as Shift, etc. etc. However this could interfere with default OS commands such as sticky keys, so it could be a problem.
Last edited by 14Gkurzepa (Jan. 30, 2017 19:03:27)
- little_kitten
-
500+ posts
(keys pressed?) block
No, there is an option for that in this block - I support!
It shouldn't be called key/s pressed? though, since a block can only report one value at one time.
Also, when no keys are pressed, does it change to “none” or something like that, or will it stay as the last one?
If it's the latter, there should be a block like this too:any key pressed? :: sensing boolean(that's supposed to be a boolean you can put into a if statement btw)
<key [any v] pressed?>
- monstermash3
-
1000+ posts
(keys pressed?) block
Support, but this might be a duplicate, I think this is a pretty commonly suggested block. (Also, this topic is a bit old… No offense.)
- monstermash3
-
1000+ posts
(keys pressed?) block
How about this instead: It could report like this: “qw” if keys q and w were down. This would act as an automatic list, as these are automatic variables:(x position)
(y position)
(direction)
(costume #)
(backdrop name)
(size)
(backdrop #)
(volume)
(tempo)
(distance to [ v])
(answer)
(mouse x)
(mouse y)
(loudness)
(video [ v] on [ v])
(timer)
([ v] of [ v])
(current [ v])
(days since 2000)
(username)
- Justiamora
-
1 post
(keys pressed?) block
So I'm working on a project with a group of kids, each making their own level and such. One kid wants to do a dance party where the sprite calls out a number and the player presses a # key. Our problem is that we want to make it that if they press the wrong number the dance party starts over again.
We haven't been able to figure out how to do this? Does anyone have any idea.
We haven't been able to figure out how to do this? Does anyone have any idea.
- -Io-
-
1000+ posts
(keys pressed?) block
Support. I think the keys should just return like they are normally represented by people: “Shift+Click green flag for turbo” “Ctrl+C, Ctrl+V to copy and paste respectively” “Shift+Ctrl+S to Save as”
So if the keys Ctrl and “ASDFGH” where pressed, it would return “Ctrl+A+S+D+F+G+H”.

So if the keys Ctrl and “ASDFGH” where pressed, it would return “Ctrl+A+S+D+F+G+H”.
This is the suggestions forum. For this kind of things you should make a new topic in the Help with Scripts forum So I'm working on a project with a group of kids, each making their own level and such. One kid wants to do a dance party where the sprite calls out a number and the player presses a # key. Our problem is that we want to make it that if they press the wrong number the dance party starts over again.
We haven't been able to figure out how to do this? Does anyone have any idea.

- theonlygusti
-
1000+ posts
(keys pressed?) block
I support, and I think that if multiple keys are pressed it should report the most recent one.
Ideally, Scratch would implement first class lists and then we could have this block report a list of the keys pressed, and it would look like this:
Ideally, Scratch would implement first class lists and then we could have this block report a list of the keys pressed, and it would look like this:
if <(keys pressed :: sensing) contains [W]?> then
end
- joefarebrother
-
500+ posts
(keys pressed?) block
Support!
I think it should report the keys that are pressed in order of their ASCII code (but this won't be confusing because that's basically numbers in order, and letters in order, uppercase before lowercase, plus some symbols in between)
For special keys like ctrl, alt, and shift, it should list those before the other letters, separated by +.
For caps lock, there should just be a
There is technically an easier (i.e. fewer blocks) workaround then checking each letter with a separate if, but it requires hacked blocks I think
I think it should report the keys that are pressed in order of their ASCII code (but this won't be confusing because that's basically numbers in order, and letters in order, uppercase before lowercase, plus some symbols in between)
For special keys like ctrl, alt, and shift, it should list those before the other letters, separated by +.
For caps lock, there should just be a
<caps lock on?:: sensing>block.
There is technically an easier (i.e. fewer blocks) workaround then checking each letter with a separate if, but it requires hacked blocks I think
define get keys pressed
set [index v] to [0]
set [keys v] to []
repeat (length of [keys v])
change [index v] by (1)
if <key pressed (item (index) of [keys v])?>
set [keys v] to (join (keys) (item (index) of [keys v])
end
end
- Techno-CAT
-
1000+ posts
(keys pressed?) block
this would be incredibly useful. however, one thing I'd see wrong with it is:
if they're pressing many keys, what would it return?
when green flag clicked
forever
if <<key pressed? = [1 ]> and <key pressed? = [a ] >> then
end
end
- scratch0maker0
-
100+ posts
(keys pressed?) block
Ok, I want a block that senses which key was pressed and returns that key.
like this:
like this:
if <(key pressed:: sensing) = [r]> thenIt would be helpful in touch typing projects.
your stuff :: grey
end
Last edited by scratch0maker0 (July 10, 2016 15:22:11)
- Ziggy741
-
1000+ posts
(keys pressed?) block
Workaround:
if <key [r v] pressed?> then
... :: grey
end