Discuss Scratch
- Discussion Forums
- » Suggestions
- » A "last key pressed" reporter (9:3:2) Now with a Q&A!
- BookOwl
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
I believe that a
This could be used for lots of projects, such as projects that don't want to use a
The general workaround for this block is not too hard, but it is long and repetitive and involves 28 if-else blocks.
Q & A
Q: What would this block do if an arrow key was pressed?
A: It would ignore it. If the ‘p’ key was pressed, and then the left arrow key was pressed, this block would return ‘p’
Q: How would this block respond to non-english characters?
A: It would just return that character! (I really don't know why this is such a big deal.)
Q: How would this deal with the space key?
A: It would either return the string “space” or the space character.
Supporters:
BookOwl
ChocolatePi
stickfiregames
TheMonsterOfTheDeep
Nether_before
Jonathan50
Prinseskat
A-no-meep
Junk_Collector
Semi-Supporters:
DaSpudLord
Cub56
Znapi
No Supporters:
Blank1234
scratchinghead
Please tell me what you think of this idea.
last key pressed ::sensing reporterblock would be very useful. As the name says, it would report the last key pressed.
This could be used for lots of projects, such as projects that don't want to use a
ask [] and waitor for projects that want to do something if a key is pressed. For example, you could do
say [Press "y" if you want to continue, any other key to exit]A workaround for this specific case is:
wait until <key [any v] pressed?>
if <(last key pressed ::sensing reporter) = [y]> then
do something ::custom
end
set [key v] to [none](Thanks to Znapi for the workaround.)
say [Press "y" if you want to continue, any other key to exit]
repeat until <not <(key) = [none]>>
if <key [y v] pressed?> then
set [key v] to [y]
else
if <key [any v] pressed?> then
set [key v] to [other]
end
end
end
if <(key) = [other]> then
stop [this script v] // exit
end
... // continue
The general workaround for this block is not too hard, but it is long and repetitive and involves 28 if-else blocks.
Q & A
Q: What would this block do if an arrow key was pressed?
A: It would ignore it. If the ‘p’ key was pressed, and then the left arrow key was pressed, this block would return ‘p’
Q: How would this block respond to non-english characters?
A: It would just return that character! (I really don't know why this is such a big deal.)
Q: How would this deal with the space key?
A: It would either return the string “space” or the space character.
Supporters:
BookOwl
ChocolatePi
stickfiregames
TheMonsterOfTheDeep
Nether_before
Jonathan50
Prinseskat
A-no-meep
Junk_Collector
Semi-Supporters:
DaSpudLord
Cub56
Znapi
No Supporters:
Blank1234
scratchinghead
Please tell me what you think of this idea.
Last edited by BookOwl (Sept. 25, 2015 23:39:59)
- DaSpudLord
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
Semi-support because of workaround, and also, how would it deal with named keys, like space and arrow keys?
- BookOwl
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
Do you REALLY want to make a script that has 31 if blocks? Really? Semi-support because of workaround, and also, how would it deal with named keys, like space and arrow keys?
It would return the name of the key. The space key would return space, and the up arrow key would return up arrow.
- DaSpudLord
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
What about for other languages, like Spanish, French, or Chinese?Do you REALLY want to make a script that has 31 if blocks? Really? Semi-support because of workaround, and also, how would it deal with named keys, like space and arrow keys?
It would return the name of the key. The space key would return space, and the up arrow key would return up arrow.
- gdpr533f604550b2f20900645890
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
- Blank1234
-
500+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
workaroundable, no support
- gdpr533f604550b2f20900645890
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
The workaround is tedious, which is the reason for the block. workaroundable, no support
- Paddle2See
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
DuplicateThanks for the link! It does look like this is a duplicate topic so I'll close it to keep the conversation all in one place.
Please use the existing topic in the link above.
- ChocolatePi
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
The Chinese have Pinyin keyboards, which is just letters with accents and the umlaut. They don't actually type in the characters xDWhat about for other languages, like Spanish, French, or Chinese?Do you REALLY want to make a script that has 31 if blocks? Really? Semi-support because of workaround, and also, how would it deal with named keys, like space and arrow keys?
It would return the name of the key. The space key would return space, and the up arrow key would return up arrow.
Obviously, it would just return the last key pressed. Simple.
- CatsUnited
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
Isn't this supposed to be closed?
- ChocolatePi
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
Wait wait wait, that's not a duplicate! That's a (keys pressed) topic, not a (last key pressed) topic!DuplicateThanks for the link! It does look like this is a duplicate topic so I'll close it to keep the conversation all in one place.
Please use the existing topic in the link above.
- gdpr533f604550b2f20900645890
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
Paddle2See probably forgot. Isn't this supposed to be closed?
- DaSpudLord
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
That's not what I was talking about. The spacebar and arrow keys probably have other names in other languages. How would those be reported?The Chinese have Pinyin keyboards, which is just letters with accents and the umlaut. They don't actually type in the characters xDWhat about for other languages, like Spanish, French, or Chinese?Do you REALLY want to make a script that has 31 if blocks? Really? Semi-support because of workaround, and also, how would it deal with named keys, like space and arrow keys?
It would return the name of the key. The space key would return space, and the up arrow key would return up arrow.
Obviously, it would just return the last key pressed. Simple.
- ChocolatePi
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
I don't know. Maybe a space key symbol? It's up to the ST. Honestly sometimes I think you're just looking for reasons to not support suggestions. I think this is a good idea.That's not what I was talking about. The spacebar and arrow keys probably have other names in other languages. How would those be reported?The Chinese have Pinyin keyboards, which is just letters with accents and the umlaut. They don't actually type in the characters xDWhat about for other languages, like Spanish, French, or Chinese?Do you REALLY want to make a script that has 31 if blocks? Really? Semi-support because of workaround, and also, how would it deal with named keys, like space and arrow keys?
It would return the name of the key. The space key would return space, and the up arrow key would return up arrow.
Obviously, it would just return the last key pressed. Simple.
- DaSpudLord
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
Space key symbol? What would that look like? And how would one type that into a textbox? And I don't no support suggestions just for the sake of arguing or no supporting- I try to use logical reasons to determine my stance. And I'm not completely no supporting- I'm semi supporting.I don't know. Maybe a space key symbol? It's up to the ST. Honestly sometimes I think you're just looking for reasons to not support suggestions. I think this is a good idea.That's not what I was talking about. The spacebar and arrow keys probably have other names in other languages. How would those be reported?The Chinese have Pinyin keyboards, which is just letters with accents and the umlaut. They don't actually type in the characters xDWhat about for other languages, like Spanish, French, or Chinese?Do you REALLY want to make a script that has 31 if blocks? Really? Semi-support because of workaround, and also, how would it deal with named keys, like space and arrow keys?
It would return the name of the key. The space key would return space, and the up arrow key would return up arrow.
Obviously, it would just return the last key pressed. Simple.
- Paddle2See
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
Good point - also made by the topic owner!Wait wait wait, that's not a duplicate! That's a (keys pressed) topic, not a (last key pressed) topic!DuplicateThanks for the link! It does look like this is a duplicate topic so I'll close it to keep the conversation all in one place.
Please use the existing topic in the link above.
Okay, let's leave it re-open and see if we can develop the idea any further

- stickfiregames
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
“space key symbol” is just a space. There are also arrow characters ↑↓←→ but they can't be typed normally, I still support it though.Space key symbol? What would that look like? And how would one type that into a textbox? And I don't no support suggestions just for the sake of arguing or no supporting- I try to use logical reasons to determine my stance. And I'm not completely no supporting- I'm semi supporting.I don't know. Maybe a space key symbol? It's up to the ST. Honestly sometimes I think you're just looking for reasons to not support suggestions. I think this is a good idea.That's not what I was talking about. The spacebar and arrow keys probably have other names in other languages. How would those be reported?The Chinese have Pinyin keyboards, which is just letters with accents and the umlaut. They don't actually type in the characters xDWhat about for other languages, like Spanish, French, or Chinese?Do you REALLY want to make a script that has 31 if blocks? Really? Semi-support because of workaround, and also, how would it deal with named keys, like space and arrow keys?
It would return the name of the key. The space key would return space, and the up arrow key would return up arrow.
Obviously, it would just return the last key pressed. Simple.
Last edited by stickfiregames (Sept. 17, 2015 21:07:03)
- BookOwl
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
Sorry that I haven't responded - I have been very busy.
In the
In the
<key [ v] pressed?>and
when [ v] key pressedblocks, when you want to check for the space key, you use “space”, and for arrow keys, you use “<direction> arrow”, where <direction> is any of up/down/left/right. I think that this block should emulate those, and return “space” when the space key is pressed, and “left arrow” when the left arrow key is pressed. Or the arrow keys could just not report, since they are not characters. Either way is fine with me.
- BookOwl
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
So, do you support or not?Sorry, I mis-understood you.Do you REALLY want to make a script that has 31 if blocks? Really? Semi-support because of workaround, and also, how would it deal with named keys, like space and arrow keys?
It would return the name of the key. The space key would return space, and the up arrow key would return up arrow.
Do this then:
<very very very long script removed by BookOwl>
Yes I know, VERY tedious. And in the blank write whatever key was pressed into a variable. Not THAT hard.
- TheMonsterOfTheDeep
-
1000+ posts
A "last key pressed" reporter (9:3:2) Now with a Q&A!
The reason I don't like the workaround is because you lose out in performance either way:
Support.
- With the giant stack of if blocks, the editor lags
- With a loop, key detection lags
Support.
- Discussion Forums
- » Suggestions
-
» A "last key pressed" reporter (9:3:2) Now with a Q&A!