Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how do i detect what key is being pressed?
- alexboy456
-
Scratcher
32 posts
how do i detect what key is being pressed?
how do i detect what key is being pressed on my keyboard?
- RynPrat
-
Scratcher
17 posts
how do i detect what key is being pressed?
<key [a key] pressed?>or
when [a key] key pressed
Last edited by RynPrat (Aug. 31, 2021 03:48:22)
- MasterofTheBrick
-
Scratcher
1000+ posts
how do i detect what key is being pressed?
This should contain what you are looking for.
- alexboy456
-
Scratcher
32 posts
how do i detect what key is being pressed?
I meant to how do i make it detect when any key is being pressed, for example if im pressing the w, then it will say that im pressing w<key [a key] pressed?>orwhen [a key] key pressedpretty basic knowledge dunno how you dont know that
- Vaibhs11
-
Scratcher
1000+ posts
how do i detect what key is being pressed?
This should help.
or do you need all keys?
forever
if <key [w v] pressed?> then
say [you're pressing W!]
end
end
or do you need all keys?
- MasterofTheBrick
-
Scratcher
1000+ posts
how do i detect what key is being pressed?
I believe @deck26 did.This should contain what you are looking for.
How… Who made this?
Essentially, all the key labels (up arrow, down arrow, a, b, c etc) are added into a list. Whenever a key is pressed, the script runs through all the items in the list and uses the sensing reporter to detect if any of those keys are indeed being pressed.
repeat (length of [key names v] :: list)
change [counter v] by (1)
if <key (item (counter) of [key names v] :: list) pressed?> then
set [Key pressed v] to (item (counter) of [key names v] :: list)
end
end
- Vaibhs11
-
Scratcher
1000+ posts
how do i detect what key is being pressed?
oh come on, I was about to do that. I guess I didn't have to do that.I believe @deck26 did.This should contain what you are looking for.
How… Who made this?
Essentially, all the key labels (up arrow, down arrow, a, b, c etc) are added into a list. Whenever a key is pressed, the script runs through all the items in the list and uses the sensing reporter to detect if any of those keys are indeed being pressed.repeat (length of [key names v] :: list)
change [counter v] by (1)
if <key (item (counter) of [key names v] :: list) pressed?> then
set [Key pressed v] to (item (counter) of [key names v] :: list)
end
end
also, turbowarp is blocked for me
- Discussion Forums
- » Help with Scripts
-
» how do i detect what key is being pressed?



