Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Problem with "any key pressed()"
- Interstellarninja
-
9 posts
Problem with "any key pressed()"
After running this code on 2 different computers I could not get the specific sensing block “any key pressed()” to work in this program. Is there anything wrong with this?
- Interstellarninja
-
9 posts
Problem with "any key pressed()"
I am troubleshooting this part to use it in a larger program, so not exactly 

- MollyandMilodog
-
100+ posts
Problem with "any key pressed()"
You may have to use a lot of broadcasts 

- Interstellarninja
-
9 posts
Problem with "any key pressed()"
yes, but I am trying to program a part so that when a user enters letter a, b, c, d … it will show sprites. Not sure if that would work?
- Nambase_Test
-
35 posts
Problem with "any key pressed()"
Last edited by Nambase_Test (April 30, 2020 17:20:43)
- Interstellarninja
-
9 posts
Problem with "any key pressed()"
It is still not working… I there should not be anything wrong with my laptop bc scratch is sensing when I use “when space clicked' but somehow not working when I use ”key any pressed()"?
- Nambase_Test
-
35 posts
Problem with "any key pressed()"
It is still not working… I there should not be anything wrong with my laptop bc scratch is sensing when I use “when space clicked' but somehow not working when I use ”key any pressed()"?
I found the issue here.
When the wait(5) ends, the code checks for that single microsecond if any key is pressed, and no human can be that fast. So you need to change your code so it constantly keeps checking if the any key is clicked instead of it immediately inputting “wrong”.
- Oumuamua
-
1000+ posts
Problem with "any key pressed()"
You need to be pressing constantly
If you do the next script, and in case it detects a key being pressed, and you release the key before sprite ends saying hello the “wrong” will be activated:
You need to be pressing without releasing any key before 5 secs. passed(to detect key pressed), also the script will run one time only, so you can´t expect a wrong message if sprite aready said hello. After running this code on 2 different computers I could not get the specific sensing block “any key pressed()” to work in this program. Is there anything wrong with this?
If you do the next script, and in case it detects a key being pressed, and you release the key before sprite ends saying hello the “wrong” will be activated:
Last edited by Oumuamua (April 30, 2020 18:28:31)
- Interstellarninja
-
9 posts
Problem with "any key pressed()"
Oh ok Thank you!
Is there any way to sense if any key was pressed and released within the three seconds and display the hello?
Is there any way to sense if any key was pressed and released within the three seconds and display the hello?
Last edited by Interstellarninja (April 30, 2020 18:49:27)
- marcelzietek2006
-
500+ posts
Problem with "any key pressed()"
Oh ok Thank you!
Is there any way to sense if any key was pressed and released within the three seconds and display the hello?
you mean like this?
- Nambase_Test
-
35 posts
Problem with "any key pressed()"
Oh ok Thank you!
Is there any way to sense if any key was pressed and released within the three seconds and display the hello?
You could make a loop with a three-second wait block that also constantly checks if any key is clicked.
- Discussion Forums
- » Help with Scripts
-
» Problem with "any key pressed()"