Discuss Scratch
- Sheep_maker
-
Scratcher
1000+ posts
(keys pressed?) block
However I really do like this use, so maybe this block could be changed to….Good point. I didn't think of that.
(letters pressed::sensing)Which reports keys in order of when they have started to be pressed, separated by no spaces (unless the space key is pressed) and also includes the other characters on the keyboard.
For now, you might have to play around with
when gf clickedto detect what keys are being pressed.
if <key (key) pressed?> then
end
Last edited by Sheep_maker (July 20, 2016 03:53:43)
- 24691357
-
Scratcher
100+ posts
(keys pressed?) block
When you type a letter, this block adds the letter to user input.OK thank you, but I didn't understand what the block was being used for in that example.Don't get it.Workaround:What about for this?if <key [r v] pressed?> then
... :: grey
endset [user input v] to (join (user input) (key pressed :: sensing))I support, but I think this might be a duplicate.
It's just a user input variable being set.
- Yanderan
-
Scratcher
100+ posts
(keys pressed?) block
Ok, I want a block that senses which key was pressed and returns that key.For personal reasons, I support because you could do this:
like this:if <(key pressed:: sensing) = [r]> thenIt would be helpful in touch typing projects.
your stuff :: grey
end
when gf clicked
forever
if <(key pressed::sensing) = [?]> then
do ya thing :3::grey
end
Last edited by Yanderan (July 21, 2016 14:08:53)
- sokoloia20
-
New Scratcher
4 posts
(keys pressed?) block
There is one unit.

Looks like that:
<key [space v] pressed?>Now added a new red block:
<all keys pressed?>This is cool!

Looks like that:
<key [all v] pressed?>
Last edited by sokoloia20 (July 29, 2016 23:36:42)
- Pepestan_Gaming
-
Scratcher
100+ posts
(keys pressed?) block
Just to clear up, the any keys pressed block already exists.
EDIT: Support, by the way!
<key [any v] pressed?>
EDIT: Support, by the way!
Last edited by Pepestan_Gaming (July 29, 2016 23:51:25)
- alexphan
-
Scratcher
1000+ posts
(keys pressed?) block
Support for this:
key pressed :: sensing reporterBut if more than one key was held, then maybe report it as a list?
Last edited by alexphan (July 30, 2016 00:19:05)
- Sheep_maker
-
Scratcher
1000+ posts
(keys pressed?) block
This wouldn't work:
What order would these keys be listed in? How would backspace, enter, tab, and shift/ctrl/alt/etc. be reported? Would the symbols be reported as well? How would it report shift+H? What if caps lock was on? etc. etc. etc.
However first class lists would make everything easier and so
<(keys pressed::sensing)=[h]>if “h” and “k” were both being pressed, assuming that first class lists aren't coming with this block. And what format would the list be: “hk” “h k” “h, k” etc.?
What order would these keys be listed in? How would backspace, enter, tab, and shift/ctrl/alt/etc. be reported? Would the symbols be reported as well? How would it report shift+H? What if caps lock was on? etc. etc. etc.
However first class lists would make everything easier and so
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:or we could change the block toif <(keys pressed :: sensing) contains [W]?> then
end
(last key pressed::sensing)
- liam48D
-
Scratcher
1000+ posts
(keys pressed?) block
As people have said, detecting one key when two keys are pressed wouldn't work with this.
So.. just make a new block, like this, right?
Oh, wait, that already exists:
So what really could be helpful is just letting any block be put into “select”, so you could put “join” in it:
Or even just make it so that you can type in the input. You know how the play-drum block has a dropdown input that's also editable?
I think it'd be best if the dropdown input was replaced with an input like that - a dropdown input that could also be typed in (Text, of course, not just numbers.) and given blocks
So.. just make a new block, like this, right?
<key [type here] pressed? :: sensing>
Oh, wait, that already exists:
<key [select v] pressed?>
So what really could be helpful is just letting any block be put into “select”, so you could put “join” in it:
<key (join [,] []) pressed?>
Or even just make it so that you can type in the input. You know how the play-drum block has a dropdown input that's also editable?
play drum (3 v) for (0.25) beats
I think it'd be best if the dropdown input was replaced with an input like that - a dropdown input that could also be typed in (Text, of course, not just numbers.) and given blocks
Last edited by liam48D (July 30, 2016 05:12:04)
- Alberknyis
-
Scratcher
1000+ posts
(keys pressed?) block
or we could change the block to(last key pressed::sensing)

This actually exists in a programming language called small basic (and probably other languages I don't know about):

As for the OP, I kind of think it's best that whatever we come up with in the end only returns one key. It is possible to account for all the keys currently pressed, with some sort of special list:
(keys currently pressed :: looks) //contains all keys currently pressed (duh)
if <(length of [keys currently pressed v] :: list) > [0]> then
something::pen
end
But this would stand out like a zebra in a field of horses. Not a good idea.
Last edited by Alberknyis (July 31, 2016 04:51:06)
- Jcaptain
-
Scratcher
10 posts
(keys pressed?) block
Support.
Last edited by Jcaptain (July 31, 2016 04:55:17)
- DimensionPvP
-
Scratcher
100+ posts
(keys pressed?) block
No Support. Why bother, if there is a workaround?
Even though it's faster and less time-consuming.
Even though it's faster and less time-consuming.
- Sheep_maker
-
Scratcher
1000+ posts
(keys pressed?) block
No Support. Why bother, if there is a workaround?It would help to give the workaround to prove that this is in fact workaroundable and to help those who urgently need this block
Even though it's faster and less time-consuming.
- qashqai
-
Scratcher
3 posts
(keys pressed?) 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)
This exists
- jromagnoli
-
Scratcher
1000+ posts
(keys pressed?) block
This existsHi there! This is an old topic, so please don't post if you aren't adding anything to the discussion. Thanks for reading and Scratch on!

I hope I handled that well
Last edited by jromagnoli (Dec. 30, 2016 14:10:03)
- kenny2scratch
-
Scratcher
500+ posts
(keys pressed?) block
I think what's going on here is a block that returns the current key being pressed.
What the block should be named is (in my opinion):
What the block should be named is (in my opinion):
(keys being pressed :: sensing)
this would be incredibly useful. however, one thing I'd see wrong with it is:I think it would return a string consisting of every key being pressed, in alphabetical order. Then if you want to say “Hello World” when the keys a, b, c, d and e are being pressed, you simply do
if they're pressing many keys, what would it return?
if <(keys being pressed :: sensing) = [abcde]> :: controlHope I made some small contribution in what, I think, is a great idea!
say [Hello World!]
- CAT_SPRITE
-
Scratcher
19 posts
(keys pressed?) block
They should also add:
<key [Enter v] pressed?>and
<key [Backspace v] pressed?>
<key [Custom, Eg. / v] pressed?>
when [Enter v] key pressed
when [Backspace v] key pressed
when [Custom, Eg. / v] key pressed
- CAT_SPRITE
-
Scratcher
19 posts
(keys pressed?) block
.
Last edited by CAT_SPRITE (March 1, 2017 20:15:32)
- CAT_SPRITE
-
Scratcher
19 posts
(keys pressed?) block
if <<(key pressed:: sensing) = (Enter:: sensing)>> then
broadcast [Next v]
end
Last edited by CAT_SPRITE (March 4, 2017 13:09:34)
- duckboycool
-
Scratcher
1000+ posts
(keys pressed?) block
They should also add:This already exists here so it would be duplicating it, but you can go and support there as well.<key [Enter v] pressed?>and
<key [Backspace v] pressed?>
<key [Custom, Eg. / v] pressed?>when [Enter v] key pressed
when [Backspace v] key pressed
when [Custom, Eg. / v] key pressed
Personally, I say no support since it just isn't that useful. You normally will have a couple of keys that may be pressed, not all of them.
Last edited by duckboycool (March 4, 2017 14:42:15)
