Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Something something with key pressings
- damasbinabdulmalik
-
New Scratcher
53 posts
Something something with key pressings
So my game keeps bugging everytime 2 keys were pressed at once, so i tried making script that detects if a key is pressed, though that only lets the script detect only ONE key at a time, what i want is that it to detect if more than one keys are pressed at the same time.
Here is my attempt at doing it, not sure if it helps though…
yeah i know using set blocks wont get me anywhere actually, but i cant really brainstorm this out man, oh and the game is uhhh, you see i have it private last time and rn im working on it on my laptop, which for some reason cant connect to the wifi… zamn, anyways any idea?
Here is my attempt at doing it, not sure if it helps though…
when [ any] key pressed
repeat until <not <key [ any] pressed?>>
set [ key press] to [1]
end
set [ key press] to [0]
yeah i know using set blocks wont get me anywhere actually, but i cant really brainstorm this out man, oh and the game is uhhh, you see i have it private last time and rn im working on it on my laptop, which for some reason cant connect to the wifi… zamn, anyways any idea?
Last edited by damasbinabdulmalik (March 20, 2026 00:45:04)
- AdaVesta_
-
Scratcher
1000+ posts
Something something with key pressings
i don't understand ur problem here, can u be more clear?
- damasbinabdulmalik
-
New Scratcher
53 posts
Something something with key pressings
i want to check 2 unspecified keys (so that means no matter what key it is, it should check that there is 2 keys pressed) are being pressed at the same time
for example i pressed t and i, d and o, and stuff but basically i want it to to be universal and not just limited to 2 specific keys…. uhh if that makes sense
for example i pressed t and i, d and o, and stuff but basically i want it to to be universal and not just limited to 2 specific keys…. uhh if that makes sense
Last edited by damasbinabdulmalik (March 20, 2026 01:36:29)
- g6g6g66g6g
-
Scratcher
100+ posts
Something something with key pressings
you can loop over each available key, i'm not sure if there's an alternative
if you want to include arrow keys, use a list instead of a variable
DEMO
set [keys v] to [abcdefghijklmnopqrstuvwxyz]
set [i v] to [1]
set [keys pressed v] to [0]
repeat (length of (keys))
if <key (letter (i) of (keys)) pressed?> then
change [keys pressed v] by (1)
end
change [i v] by (1)
end
if you want to include arrow keys, use a list instead of a variable
DEMO
- damasbinabdulmalik
-
New Scratcher
53 posts
Something something with key pressings
hmmm i think i can tug this one out, thanks man
- damasbinabdulmalik
-
New Scratcher
53 posts
Something something with key pressings
actually nevermind ive found an alternative scriptohmygo
- g6g6g66g6g
-
Scratcher
100+ posts
Something something with key pressings
what's the alternative you found? i'm curious.
- Discussion Forums
- » Help with Scripts
-
» Something something with key pressings