Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Key Pressed from list or variable (solved)
- mstone326
-
1000+ posts
Key Pressed from list or variable (solved)
I created a project for my primary students at school and would like to add keyboard inputs for the 1st and 2nd grade as they learn the keyboard. Before I throw all if key a pressed, then…..
I searched the web and the site for key pressed and only came up with hacked blocks. Is there a way to use, if key item i from list pressed? If not I can certainly do a bunch of if then else but wanted to check here first after my unsuccessful search.
Thanks in advance. I will share the project but it has nothing to do with its current state. Just looking at add key press events to a list.
https://scratch.mit.edu/projects/213467974/
I searched the web and the site for key pressed and only came up with hacked blocks. Is there a way to use, if key item i from list pressed? If not I can certainly do a bunch of if then else but wanted to check here first after my unsuccessful search.
Thanks in advance. I will share the project but it has nothing to do with its current state. Just looking at add key press events to a list.
https://scratch.mit.edu/projects/213467974/
Last edited by mstone326 (April 1, 2018 13:13:48)
- apple502j
-
1000+ posts
Key Pressed from list or variable (solved)
Scratch 3.0 (Will Be Released August) will support that
- asivi
-
1000+ posts
Key Pressed from list or variable (solved)
I created a project for my primary students at school and would like to add keyboard inputs for the 1st and 2nd grade as they learn the keyboard. Before I throw all if key a pressed, then…..
I searched the web and the site for key pressed and only came up with hacked blocks. Is there a way to use, if key item i from list pressed? If not I can certainly do a bunch of if then else but wanted to check here first after my unsuccessful search.
Thanks in advance. I will share the project but it has nothing to do with its current state. Just looking at add key press events to a list.
https://scratch.mit.edu/projects/213467974/
Hi, If you do not want to use event blocks or the if_else stuff, then yes, you will need a hacked block.
In case you need any key(number, or letter, or symbol, or special related to text editing) I'd suggest you go to projects by @griffpatch and search through them.
- mstone326
-
1000+ posts
Key Pressed from list or variable (solved)
I created a project for my primary students at school and would like to add keyboard inputs for the 1st and 2nd grade as they learn the keyboard. Before I throw all if key a pressed, then…..
I searched the web and the site for key pressed and only came up with hacked blocks. Is there a way to use, if key item i from list pressed? If not I can certainly do a bunch of if then else but wanted to check here first after my unsuccessful search.
Thanks in advance. I will share the project but it has nothing to do with its current state. Just looking at add key press events to a list.
https://scratch.mit.edu/projects/213467974/
Hi, If you do not want to use event blocks or the if_else stuff, then yes, you will need a hacked block.
In case you need any key(number, or letter, or symbol, or special related to text editing) I'd suggest you go to projects by @griffpatch and search through them.
Thanks. I was hoping not to use hacked blocks. I saw Griffpatch's project and a few others that used hacked blocks. I was hoping to not use them. I have my answer, I will use if then else blocks for the keypress events.
Thank you.
- Scratch-Minion
-
1000+ posts
Key Pressed from list or variable (solved)
Hi mstone326.
I programmed this project a long time ago but never released it.
“Letter Key Detect Custom Block” https://scratch.mit.edu/projects/136788320/
When a key press is detected by “When any key pressed” the custom block (not hacked) in this project tells you what letter key A-Z was pressed.
The code can be modified for other Scratch detectable keys eg. 0-9.
I hope it helps.
I programmed this project a long time ago but never released it.
“Letter Key Detect Custom Block” https://scratch.mit.edu/projects/136788320/
When a key press is detected by “When any key pressed” the custom block (not hacked) in this project tells you what letter key A-Z was pressed.
The code can be modified for other Scratch detectable keys eg. 0-9.
I hope it helps.
- mstone326
-
1000+ posts
Key Pressed from list or variable (solved)
Hi mstone326.
I programmed this project a long time ago but never released it.
“Letter Key Detect Custom Block” https://scratch.mit.edu/projects/136788320/
When a key press is detected by “When any key pressed” the custom block (not hacked) in this project tells you what letter key A-Z was pressed.
The code can be modified for other Scratch detectable keys eg. 0-9.
I hope it helps.
Great, thank you. I will definitely look through those scripts to see if I can use that to streamline my code for key presses. My thought was is ‘A’ was costume1 of the letter sprite, then ‘A’ would be item 1 of the keypress list. Would save me from all the if then else blocks.
I will look at your example and see if I can adapt it. Much appreciate. Thank you.
- asivi
-
1000+ posts
Key Pressed from list or variable (solved)
Hi mstone326.
I programmed this project a long time ago but never released it.
“Letter Key Detect Custom Block” https://scratch.mit.edu/projects/136788320/
When a key press is detected by “When any key pressed” the custom block (not hacked) in this project tells you what letter key A-Z was pressed.
The code can be modified for other Scratch detectable keys eg. 0-9.
I hope it helps.
Great, thank you. I will definitely look through those scripts to see if I can use that to streamline my code for key presses. My thought was is ‘A’ was costume1 of the letter sprite, then ‘A’ would be item 1 of the keypress list. Would save me from all the if then else blocks.
I will look at your example and see if I can adapt it. Much appreciate. Thank you.
Sincerly, i love the @Scratch-Minion project but i love simple things too, and i think that “when any key pressed” plus “if_then_else” is better.
I'd encourage you to use a hacked <key()pressed)> block, it is easy to understand by your pupils and cheap.
You can see how simple it works in the project you can find above the nice little evil in my signature.
Last edited by asivi (April 1, 2018 01:09:49)
- crisostimo
-
500+ posts
Key Pressed from list or variable (solved)
I've resigned myself to using griffpatch's method.
I keep a private project that has a keyboard input sprite that I use when I need to. I was able to clean his code up a bit too.
But why I am really writing is in response to @apple502j - is there documentation anywhere about what is in Scratch 3.0? I'm super interested in that.
I keep a private project that has a keyboard input sprite that I use when I need to. I was able to clean his code up a bit too.
But why I am really writing is in response to @apple502j - is there documentation anywhere about what is in Scratch 3.0? I'm super interested in that.
- crisostimo
-
500+ posts
Key Pressed from list or variable (solved)
Oh, I found it - preview.scratch.mit.edu
Very little block-wise has changed in the preview at least. Hopefully some of the performance bugs are fixed though and we get a little better anti-aliasing. I look forward to giving the real thing a go in the future.
Though getting back to the original topic, I'm curious about the new ability to put variables and expressions in the is key pressed block. Scratch generally treats a as equal to A so will we be able to detect a capital letter - will we be able to check for capitalization? The hacked blocks in the griffpatch hack talked about earlier works against ASCII which can allow detecting things like the shift keys down. Will that be supported?
Very little block-wise has changed in the preview at least. Hopefully some of the performance bugs are fixed though and we get a little better anti-aliasing. I look forward to giving the real thing a go in the future.
Though getting back to the original topic, I'm curious about the new ability to put variables and expressions in the is key pressed block. Scratch generally treats a as equal to A so will we be able to detect a capital letter - will we be able to check for capitalization? The hacked blocks in the griffpatch hack talked about earlier works against ASCII which can allow detecting things like the shift keys down. Will that be supported?
Last edited by crisostimo (April 1, 2018 04:14:59)
- mstone326
-
1000+ posts
Key Pressed from list or variable (solved)
Thank you everyone for the input. I went with the if then else method. It is ugly but works and is easy to understand. This topic can be closed.
Last edited by mstone326 (April 1, 2018 13:15:22)
- Discussion Forums
- » Help with Scripts
-
» Key Pressed from list or variable (solved)