Discuss Scratch

Cream_E_Cookie
Scratcher
1000+ posts

(keys pressed?) block

Support if:
it is a LAST key pressed (by millisecond)
Cute_Boot-art
Scratcher
13 posts

(keys pressed?) block

Cream_E_Cookie wrote:

Support if:
it is a LAST key pressed (by millisecond)
TheMasterKing107
Scratcher
36 posts

(keys pressed?) block

Support
TheMasterKing107
Scratcher
36 posts

(keys pressed?) block

(key pressed contains []::sensing)
(key pressed::sensing)
I support both of them.

Last edited by TheMasterKing107 (Sept. 8, 2015 13:35:17)

scratchinghead
Scratcher
1000+ posts

(keys pressed?) block

Support.
key pressed included [] :: sensing boolean
scrooge200
Scratcher
1000+ posts

(keys pressed?) block

Support.
Arthurtilly
Scratcher
1000+ posts

(keys pressed?) block

kvackkvack wrote:

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)
There is a boolean that does that, the
<key [ v] pressed?>
block has an “any” option.

peterjhc wrote:

ALSO add Shift, Enter, Delete, Tab, Shift, and symbol support (period, comma, slash, etc.)
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.
julianandwill
Scratcher
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
Scratcher
5 posts

(keys pressed?) block

The idea of having a
<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
Scratcher
500+ posts

(keys pressed?) block

kvackkvack wrote:

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)
No, there is an option for that in this block -
<key [any v] pressed?>
monstermash3
Scratcher
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
Scratcher
1000+ posts

(keys pressed?) block

julianandwill wrote:

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)
How about this instead: It could report like this: “qw” if keys q and w were down.
Justiamora
Scratcher
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.
-Io-
Scratcher
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”.


Justiamora wrote:

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.
This is the suggestions forum. For this kind of things you should make a new topic in the Help with Scripts forum
JavierR100
Scratcher
500+ posts

(keys pressed?) block

Support for
(key/s pressed? :: sensing)
block
theonlygusti
Scratcher
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:

if <(keys pressed :: sensing) contains [W]?> then
end
joefarebrother
Scratcher
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
<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
Scratcher
1000+ posts

(keys pressed?) block

ChocolatePi wrote:

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
Scratcher
100+ posts

(keys pressed?) block

Ok, I want a block that senses which key was pressed and returns that key.
like this:
if <(key pressed:: sensing) = [r]> then
your stuff :: grey
end
It would be helpful in touch typing projects.

Last edited by scratch0maker0 (July 10, 2016 15:22:11)

Ziggy741
Scratcher
1000+ posts

(keys pressed?) block

Workaround:

if <key [r v] pressed?> then
... :: grey
end

Powered by DjangoBB