Discuss Scratch

MrSherlockHolmes
Scratcher
500+ posts

(keys pressed?) block

 (key/s pressed? :: sensing) 
Would be useful because the workaround is very complicated, and it help with text editors, chatbots and simulations.
<key [L v] pressed?>
could be exchanged with
<(key/s pressed? :: sensing)=[L]>
So what do you think?
MrSherlockHolmes
kvackkvack
Scratcher
500+ 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)
MrSherlockHolmes
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)
Thanks! It would probably become n/a. What do you mean by ‘a block can only report one value at a time’?
peterjhc
Scratcher
43 posts

(keys pressed?) block

ALSO add Shift, Enter, Delete, Tab, Shift, and symbol support (period, comma, slash, etc.)
ChocolatePi
Scratcher
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?
Thepuzzlegame
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?
I'm assuming it would return the first key pressed, or maybe an array of all the keys pressed?

Also a neat use for this block would be:
when green flag clicked
say [Press any key to continue...]
wait until <not <(keys pressed::sensing) = []>
TheHockeyist
Scratcher
1000+ posts

(keys pressed?) block

peterjhc wrote:

ALSO add Shift, Enter, Delete, Tab, Shift, and symbol support (period, comma, slash, etc.)
I suggested that before…

As for the original suggestion, no support. What would this be used for? Hopefully not this:
forever
if (any key pressed :: sensing) then
crash Scratch
end

Last edited by TheHockeyist (Jan. 4, 2015 01:18:39)

Thepuzzlegame
Scratcher
1000+ posts

(keys pressed?) block

TheHockeyist wrote:

As for the original suggestion, no support. What would this be used for? Hopefully not this:
forever
if (any key pressed :: sensing) then
crash Scratch
end
I for one think this block has many uses such as the one I mentioned below. And as for crashing Scratch the same could be down simply with.
when green flag clicked
crash scratch
jrezneckbhds
Scratcher
500+ posts

(keys pressed?) block

Support!
MrSherlockHolmes
Scratcher
500+ posts

(keys pressed?) block

TheHockeyist wrote:

peterjhc wrote:

ALSO add Shift, Enter, Delete, Tab, Shift, and symbol support (period, comma, slash, etc.)
I suggested that before…

As for the original suggestion, no support. What would this be used for? Hopefully not this:
forever
if (any key pressed :: sensing) then
crash Scratch
end
It's more:
(keys pressed)
but I see where your coming from. It would probably say n/a if you press to many keys, but I'm not sure. How much data do you think scratch could cope with?
MrSherlockHolmes
Scratcher
500+ posts

(keys pressed?) block

Thepuzzlegame wrote:

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?
I'm assuming it would return the first key pressed, or maybe an array of all the keys pressed?

Also a neat use for this block would be:
when green flag clicked
say [Press any key to continue...]
wait until <not <(keys pressed::sensing) = []>
True, it would be nice to use it like that, just one question, would space be or ? Because if they press space, maybe nothing would happen, if it senses as null…
MrSherlockHolmes
Scratcher
500+ 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?
It would probably become n/a. But I'm not really sure at what point ‘too many keys’ are pressed… How much can scratch cope with?

Last edited by MrSherlockHolmes (Jan. 4, 2015 11:26:34)

MushroomMan99
Scratcher
100+ posts

(keys pressed?) block

Support. This would make a safe-chat easier to make
set [chat message v] to (key pressed:: sensing) 
MrSherlockHolmes
Scratcher
500+ posts

(keys pressed?) block

MushroomMan99 wrote:

Support. This would make a safe-chat easier to make
set [chat message v] to (key pressed:: sensing) 
Thanks.
stickfiregames
Scratcher
1000+ posts

(keys pressed?) block

(Updated this post, changes in bold)

Support for
<any key pressed? :: sensing>
This now exists as an option in the dropdown of the <key [] pressed?> block.


Not sure about
(keys pressed :: sensing)
because of ambiguity:
(1) If multiple keys are pressed, how would it format it? What order would they be in? How would they be separated (with a space, or without)? Support if it only returns the last key to be pressed if multiple keys are, or returns nothing if no keys are pressed.
(2) The named keys have different names in different languages or different operating systems, so someone who did not use the same language and OS as the block reported might be confused when it did not appear to detect keys. Since the block will probably be used for text entry, it might be better if it just didn't report non-text keys at all. That way you wouldn't have to filter them out from your input, and there are few enough of them that you could just use the key pressed block for that instead.

Last edited by stickfiregames (Nov. 11, 2015 13:24:42)

Alberknyis
Scratcher
1000+ posts

(keys pressed?) block

TheHockeyist wrote:

peterjhc wrote:

ALSO add Shift, Enter, Delete, Tab, Shift, and symbol support (period, comma, slash, etc.)
I suggested that before…

As for the original suggestion, no support. What would this be used for? Hopefully not this:
forever
if (any key pressed :: sensing) then
crash Scratch
end

Guess what:
when green flag clicked
crash Scratch::grey

So basically according to you even the green flag hat block can be a threat.

As for the original thing, I'd like to suggest a solution to this problem:

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?

My idea is to make use put the keys pressed in an imaginary list(or whatever it's called), and combine it with this block:
(keys pressed includes []?::sensing)
Any characters typed in there will make the boolean return true when any of them are pressed.
samanyolu
Scratcher
1000+ posts

(keys pressed?) block

Support.
JimJamGo_
Scratcher
3 posts

(keys pressed?) block

Yes that would be nice

Last edited by JimJamGo_ (May 2, 2015 07:58:04)

tim556688
Scratcher
82 posts

(keys pressed?) block

Support
rollercoasterfan
Scratcher
1000+ posts

(keys pressed?) block

Support.

Powered by DjangoBB