Discuss Scratch
- XayCraft360
-
100+ posts
(keys pressed?) block
Especially with 3.0, there's a much easier way. I support. This would make things so much easier - instead of doingwhen green flag clickedand then repeat that 25 more times. Very good idea!
forever
if <> then
<key [a] pressed?>
set [text] to (join (foo) [a])
end
end
You can use something like thisdefine 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
-
33 posts
(keys pressed?) block
Is it possible to do this:
Thanks in advance -Ivan
when green flag clicked
forever
if <key [ delete] pressed?> then
(your stuff)
end
end
Thanks in advance -Ivan
- Vibrantzin
-
33 posts
(keys pressed?) block
I mean:
when green flag clicked
forever
if <key [ delete] pressed?> then
your stuff
end
end
- coder2045
-
1000+ posts
(keys pressed?) block
I don't think so. Also, please don't necropost. Necroposting is bumping an old topic without adding anything to the discussion. I mean:when green flag clicked
forever
if <key [ delete] pressed?> then
your stuff
end
end
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
-
1000+ posts
(keys pressed?) block
With Scratch 3.0: 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?
<(keys pressed::sensing) contains [r]?:: operators>Done.
- michaelchen2009
-
8 posts
(keys pressed?) block
sorry for necroposting 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 sofirst 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 to Ideally, Scratch would implementif <(keys pressed :: sensing) contains [W]?> then
end(last key pressed::sensing)
It can detect keys pressed through javascript. it doesnt detect outputs of keys
- RedBigz
-
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
-
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
-
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:
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!
(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
-
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:Scratch doesn't support the ctrl key at all. Also, please use the [/color] tag instead of [color=black].(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!
- PizzaAddict4Life
-
1000+ posts
(keys pressed?) block
ooook
Edit… ????? What!? I don't know what I meant
Edit… ????? What!? I don't know what I meant
Last edited by PizzaAddict4Life (Sept. 7, 2020 04:08:58)
- scramaso
-
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?
Would it output the two key together or only the last one pressed?
- Executec
-
100+ posts
(keys pressed?) block
Okay. Support. But just try
<last key pressed> :: sensingPeople have just been mostly saying the exact same points, this seems like the simplest answer.
- sportfan999
-
1000+ posts
(keys pressed?) block
Workaround: Ok, I want a block that senses which key was pressed and returns that key.
like this:if <(key pressed:: sensing) = [r]> thenIt would be helpful in touch typing projects.
your stuff :: grey
end
Create a variable called “key pressed”
(key pressed)and then do this code:
when green flag clickedI've seen other workarounds, like:
forever
if <key [whatever letter you want v] pressed?> then
set [key pressed v] to [whatever letter you want]
Because of the ridiculously easy workarounds, Suppose I have a custom block called text ().no support.
Instead of this,when [a v] key pressedI can do this:
text (a) :: custom
when [b v] key pressed
text (b):: custom
when [c v] key pressed
text (c) :: custom
and on... :: greywhen green flag clicked
forever
if <key [any key v] pressed?> then
text (key pressed :: sensing) :: custom
end
end
Last edited by sportfan999 (Sept. 6, 2020 20:45:16)
- barrettada95
-
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
But what if it could tell you all of the keys you're pressing
Last edited by barrettada95 (Oct. 6, 2020 15:17:28)
- TopicBumper
-
100+ posts
(keys pressed?) block
Bump after
Perhaps I shouldn't bump at 9:23:30 EST. I'm doing this to get some discussion and that's not exactly happening.
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.