Discuss Scratch

TheBurger82
Scratcher
100+ posts

(keys pressed?) block

Support!
XayCraft360
Scratcher
100+ posts

(keys pressed?) block

powercon5 wrote:

Code_Spawner wrote:

I support. This would make things so much easier - instead of doing
when green flag clicked
forever
if <> then
<key [a] pressed?>
set [text] to (join (foo) [a])
end
end
and then repeat that 25 more times. Very good idea!
Especially with 3.0, there's a much easier way.
You can use something like this
define Key pressed
set [Key pressed v] to []
set [i v] to [0]
repeat (length of [ qwertyuiopasdfghjklzxcvbnm1234567890])
change [i v] by (1)
if <key (letter (i) of [ qwertyuiopasdfghjklzxcvbnm1234567890]) pressed?> then
set [key pressed v] to (letter (i) of [ qwertyuiopasdfghjklzxcvbnm1234567890])
stop [this script v]

end

end

But they are asking for a Reporter, and until Custom Reporters are added, this suggestion still lives, and when they do get added, your workaround would be possible,

Because of this, I support this suggestion for now
Vibrantzin
Scratcher
33 posts

(keys pressed?) block

Is it possible to do this:
when green flag clicked
forever
if <key [ delete] pressed?> then
(your stuff)
end
end

Thanks in advance -Ivan
Vibrantzin
Scratcher
33 posts

(keys pressed?) block

I mean:
when green flag clicked
forever
if <key [ delete] pressed?> then
your stuff
end
end
coder2045
Scratcher
1000+ posts

(keys pressed?) block

IvanChan3 wrote:

I mean:
when green flag clicked
forever
if <key [ delete] pressed?> then
your stuff
end
end
I don't think so. Also, please don't necropost. Necroposting is bumping an old topic without adding anything to the discussion.
As for my opinion, 75% support. I wouldn't use it a lot but lots of others seem to need it.

Last edited by coder2045 (April 21, 2020 22:23:28)

coder2045
Scratcher
1000+ posts

(keys pressed?) block

Sheep_maker wrote:

What if multiple keys are pressed? What would it report?
Say the key “r” was pressed. Obviously, the block would report “r”
But if both “r” and “g” are pressed, the block wouldn't be “r” anymore, so
<(keys pressed::sensing)=[r]>
Wouldn't work even though the r key is being pressed.

And how'll the cursor keys, enter/return, backspace/delete, delete/delete, and ctrl/command/shift/alt/option/etc. be reported via this block?
With Scratch 3.0:
<(keys pressed::sensing) contains [r]?:: operators>
Done.
michaelchen2009
Scratcher
8 posts

(keys pressed?) block

Sheep_maker wrote:

This wouldn't work:
<(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

theonlygusti wrote:

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
or we could change the block to
(last key pressed::sensing)
sorry for necroposting
It can detect keys pressed through javascript. it doesnt detect outputs of keys
RedBigz
Scratcher
29 posts

(keys pressed?) block

how i would have done it is this
when [any v] key pressed
set [charlist v] to [`~1!2@3#4$5%6^7&8*9(0)-_=+qwertyuiop[{\]}\|asdfghjkl;:'"zxcvbnm,<.>/?]
set [loop v] to [0]
repeat (length of (charlist))
change [loop v] by [1]
if <key (letter (loop) of (charlist)) pressed> then
set [input v] to (join (input) (letter (loop) of (charlist))
end
end
RedBigz
Scratcher
29 posts

(keys pressed?) block

how i would have done it is this
when [any v] key pressed
set [charlist v] to [`~1!2@3#4$5%6^7&8*9(0)-_=+qwertyuiop[{\]}\|asdfghjkl;:'"zxcvbnm,<.>/?]
set [loop v] to [0]
repeat (length of (charlist))
change [loop v] by [1]
if <key (letter (loop) of (charlist)) pressed> then
set [input v] to (join (input) (letter (loop) of (charlist))
end
end
PizzaAddict4Life
Scratcher
1000+ posts

(keys pressed?) block

SUPPORT!. I have recently wanted to make it so that if you pressed the “ctrl” key it would do something, using this workaround:

(join [ctrl] [])

(join [control] [])

But neither of those work. So I would want to know what the control key is listed as so I can do that.

FULL SUPPORT!

Last edited by PizzaAddict4Life (Sept. 7, 2020 04:08:28)

Maximouse
Scratcher
1000+ posts

(keys pressed?) block

PizzaAddict4Life wrote:

SUPPORT!. I have recently wanted to make it so that if you pressed the “ctrl” key it would do something, using this workaround:

(join [ctrl] [])

(join [control] [])

But neither of those work. So I would want to know what the control key is listed as so I can do that.

FULL SUPPORT!
Scratch doesn't support the ctrl key at all. Also, please use the [/color] tag instead of [color=black].
PizzaAddict4Life
Scratcher
1000+ posts

(keys pressed?) block

ooook

Edit… ????? What!? I don't know what I meant

Last edited by PizzaAddict4Life (Sept. 7, 2020 04:08:58)

-Dragonster-
Scratcher
38 posts

(keys pressed?) block

support
scramaso
Scratcher
500+ posts

(keys pressed?) block

But how would it work if two keys are pressed at the same time?

Would it output the two key together or only the last one pressed?
Executec
Scratcher
100+ posts

(keys pressed?) block

Okay. Support. But just try
<last key pressed>  :: sensing
People have just been mostly saying the exact same points, this seems like the simplest answer.
Xpexdex
Scratcher
87 posts

(keys pressed?) block

(key pressed)
Is Not A block
sportfan999
Scratcher
1000+ posts

(keys pressed?) block

scratch0maker0 wrote:

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.
Workaround:
Create a variable called “key pressed”
(key pressed)
and then do this code:
when green flag clicked
forever
if <key [whatever letter you want v] pressed?> then
set [key pressed v] to [whatever letter you want]
I've seen other workarounds, like:

scratch0maker0 wrote:

Suppose I have a custom block called text ().
Instead of this,
when [a v] key pressed
text (a) :: custom
when [b v] key pressed
text (b):: custom
when [c v] key pressed
text (c) :: custom

and on... :: grey
I can do this:
when green flag clicked
forever
if <key [any key v] pressed?> then
text (key pressed :: sensing) :: custom
end
end
Because of the ridiculously easy workarounds, no support.

Last edited by sportfan999 (Sept. 6, 2020 20:45:16)

barrettada95
Scratcher
6 posts

(keys pressed?) block

Guess I wasn't the only one who thought of this

But what if it could tell you all of the keys you're pressing

Last edited by barrettada95 (Oct. 6, 2020 15:17:28)

fdreerf
Scratcher
1000+ posts

(keys pressed?) block

Bump after this topic has been merged.
TopicBumper
New Scratcher
100+ posts

(keys pressed?) block

Bump after

fdreerf wrote:

Bump after this topic has been merged.

Perhaps I shouldn't bump at 9:23:30 EST. I'm doing this to get some discussion and that's not exactly happening.

Powered by DjangoBB