Discuss Scratch

Thorlake
Scratcher
2 posts

Multiple keys pressed at once

I've been making a scratch project for around like 2 months now and for some reason it only detects one key at a time. Now I've found some loopholes around this, like if I click each key individually then click all 4 It'll detect all at once, but It's a rhythm game so I can't do that or else It'll ruin some of the songs. Any ideas?
xylidine
New Scratcher
500+ posts

Multiple keys pressed at once

You can easily detect multiple keys at once.

if <<key [a v] pressed?> and <key [b v] pressed?>> then //this detects if 'a' and 'b' is being pressed at the same time
... :: #808080
end

The idea is to use the “and” block to check if both parts of the if-statement are true.

Last edited by xylidine (Jan. 23, 2026 03:39:28)

awesome-llama
Scratcher
1000+ posts

Multiple keys pressed at once

Be aware that keyboards often have a hardware limitation for which keys can be detected simultaneously, see key rollover.
Thorlake
Scratcher
2 posts

Multiple keys pressed at once

xylidine wrote:

You can easily detect multiple keys at once.

if <<key [a v] pressed?> and <key [b v] pressed?>> then //this detects if 'a' and 'b' is being pressed at the same time
... :: #808080
end

The idea is to use the “and” block to check if both parts of the if-statement are true.

The problem with this is that I have 4 keys that I need to keep track of and that would take a large amount of blocks. If I have to I'll do that but for me at least I'm hoping it can be more efficient. For me at least this script (not exactly the script but should work the same) doesn't detect multiple
when green flag clicked
forever
if <key [ v] pressed?> then

end
if <key [ v] pressed?> then

end
MineTurte
Scratcher
1000+ posts

Multiple keys pressed at once

Thorlake wrote:

xylidine wrote:

You can easily detect multiple keys at once.

if <<key [a v] pressed?> and <key [b v] pressed?>> then //this detects if 'a' and 'b' is being pressed at the same time
... :: #808080
end

The idea is to use the “and” block to check if both parts of the if-statement are true.

The problem with this is that I have 4 keys that I need to keep track of and that would take a large amount of blocks. If I have to I'll do that but for me at least I'm hoping it can be more efficient. For me at least this script (not exactly the script but should work the same) doesn't detect multiple
when green flag clicked
forever
if <key [ v] pressed?> then

end
if <key [ v] pressed?> then

end
You have the right idea but to detect multiple the simpliest way is to just make multiple forever blocks for each key needed.

Powered by DjangoBB