Discuss Scratch
- Discussion Forums
- » Bugs and Glitches
- » "When key pressed" blocks not working
- jbmsappcreators
-
Teacher
3 posts
"When key pressed" blocks not working
My students and I are both having issues where the key pressed sensing blocks are not working
We have the following code:
Link to project showing the bug:
https://scratch.mit.edu/projects/1272702833
Scratch username: jbmsappcreators
My browser / operating system: Windows NT 10.0, Chrome 144.0.0.0, No Flash version detected
Edit: I forgot to mention, my older projects that use the exact same blocks are working fine. It seems to only be projects created recently (these ones were started this past Monday)
We have the following code:
when green flag clicked
forever
if <key [ right arrow] pressed?> then
change x by (10)
end
if <key [ left arrow] pressed?> then
change x by (-10)
end
end
Link to project showing the bug:
https://scratch.mit.edu/projects/1272702833
Scratch username: jbmsappcreators
My browser / operating system: Windows NT 10.0, Chrome 144.0.0.0, No Flash version detected
Edit: I forgot to mention, my older projects that use the exact same blocks are working fine. It seems to only be projects created recently (these ones were started this past Monday)
Last edited by jbmsappcreators (Jan. 29, 2026 17:25:23)
- nembence
-
Scratcher
500+ posts
"When key pressed" blocks not working
It seems like the Green Flag button can get focused now. If you click on the project to give it focus, it starts working
- jbmsappcreators
-
Teacher
3 posts
"When key pressed" blocks not working
That worked! Thank you so much!
- redspacecat
-
Scratcher
1000+ posts
"When key pressed" blocks not working
It seems like the Green Flag button can get focused now. If you click on the project to give it focus, it starts workingInteresting. Is that new?
- cookedasparagus8
-
Scratcher
1000+ posts
"When key pressed" blocks not working
Cannot replicate on My browser / operating system: Windows 11 Home, Firefox 148.0, No Flash version detected
- medians
-
Scratcher
1000+ posts
"When key pressed" blocks not working
Cannot replicate on My browser / operating system: Windows 11 Home, Firefox 148.0, No Flash version detectedI think I figured how to replicate now. You have to click the green flag (not the one on the stage, as you don't seem to be able to replicate if you do that) to start the project, and then the green flag is focused so the keys don't actually do anything when you press them until you click off of the green flag.
Last edited by medians (Jan. 30, 2026 15:25:57)
- redspacecat
-
Scratcher
1000+ posts
"When key pressed" blocks not working
I think I figured how to replicate now. You have to click the green flag (not the one on the stage, as you don't seem to be able to replicate if you do that) to start the project, and then the green flag is focused so the keys don't actually do anything when you press them until you click off of the green flag.I can replicate using that method.
- cozygamer125
-
New Scratcher
1 post
"When key pressed" blocks not working
I am having the same issue along with my students.
In our project we currently have two “when green flag clicked” blocks with their own scripts. One runs a costume change for animation and the other controls movement.
When clicking the green flag on the stage, only the animation will run but the movement keys won't work.
If I click only on the green flag on the movement script, the movement will work but the animation won't run.
Is there some sort of glitch happening because if we can't use the green flag button the stage to run the entire game, well that's not good!
Even when I click the green flag on the project page, it does the same thing.
Project with issue linked: https://scratch.mit.edu/projects/1270837817
In our project we currently have two “when green flag clicked” blocks with their own scripts. One runs a costume change for animation and the other controls movement.
When clicking the green flag on the stage, only the animation will run but the movement keys won't work.
If I click only on the green flag on the movement script, the movement will work but the animation won't run.
Is there some sort of glitch happening because if we can't use the green flag button the stage to run the entire game, well that's not good!
Even when I click the green flag on the project page, it does the same thing.
Project with issue linked: https://scratch.mit.edu/projects/1270837817
- jbmsappcreators
-
Teacher
3 posts
"When key pressed" blocks not working
On the project page, if I click the green flag that is on the actualy game screen, the bug doesn't happen. But if I use the one above the play space, it happens.
Super annoying. Glad I have a work-around, but annoying still.
Super annoying. Glad I have a work-around, but annoying still.
- D-ScratchNinja
-
Scratcher
1000+ posts
"When key pressed" blocks not working
At first, I thought it was pretty neat that you could now use the green flag with your keyboard, but it seems like literally everything keyboard-focusable seems to “capture” key presses so that they don't control the project. Only once you use your mouse to click on something else does keyboard input work, which is not really great if keyboard controls were added to the webpage for accessibility purposes… (what if you can't use a mouse? I know Scratch can't generally be used without a pointing device, but you should at least be able to do basic navigation.)
A simple fix for the Scratch developers would be to un-focus the green flag after it is pressed so that keyboard blocks work.
Slider variables do this too, by the way.
A simple fix for the Scratch developers would be to un-focus the green flag after it is pressed so that keyboard blocks work.
Slider variables do this too, by the way.
- cookedasparagus8
-
Scratcher
1000+ posts
"When key pressed" blocks not working
I think I figured how to replicate now. You have to click the green flag (not the one on the stage, as you don't seem to be able to replicate if you do that) to start the project, and then the green flag is focused so the keys don't actually do anything when you press them until you click off of the green flag.Can replicate now.
- lholloma
-
Teacher
2 posts
"When key pressed" blocks not working
Is there a command to set focus? Most of my kid's projects are broken now because of this. The final is due tomorrow.
- BitcoinFarmer
-
New Scratcher
500+ posts
"When key pressed" blocks not working
The flappy bird is not working due to you pressing the flag and you can't immediately jump and instead crash into a pipe until you get it to listen to keys
- nembence
-
Scratcher
500+ posts
"When key pressed" blocks not working
Is there a command to set focus? Most of my kid's projects are broken now because of this. The final is due tomorrow.You can put this into an empty sprite:
when green flag clicked
ask [] and wait // removes focus from green flag by focusing a text input
when green flag clicked
wait (0.01) seconds
stop [other scripts in sprite v] // removes the text input so that isn't focused either
Edit: I've also made a backpackable version
Last edited by nembence (Today 13:12:59)
- colinmacc
-
Scratcher
1000+ posts
"When key pressed" blocks not working
EDIT: Nevermind, beaten to it!
Last edited by colinmacc (Today 13:12:08)
- lholloma
-
Teacher
2 posts
"When key pressed" blocks not working
Is there a command to set focus? Most of my kid's projects are broken now because of this. The final is due tomorrow.You can put this into an empty sprite:when green flag clicked
ask [] and wait // removes focus from green flag by focusing a text inputwhen green flag clicked
wait (0.01) seconds
stop [other scripts in sprite v] // removes the text input so that isn't focused either
Edit: I've also made a backpackable version
Thank you
- Discussion Forums
- » Bugs and Glitches
-
» "When key pressed" blocks not working