Discuss Scratch

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?

RynPrat wrote:

<key [a key] pressed?>
or
when [a key] key pressed
pretty basic knowledge dunno how you dont know that
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
alexboy456
Scratcher
32 posts

how do i detect what key is being pressed?

MasterofTheBrick wrote:

This should contain what you are looking for.

How… Who made this?
Vaibhs11
Scratcher
1000+ posts

how do i detect what key is being pressed?

This should help.

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?

alexboy456 wrote:

MasterofTheBrick wrote:

This should contain what you are looking for.

How… Who made this?
I believe @deck26 did.

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?

MasterofTheBrick wrote:

alexboy456 wrote:

MasterofTheBrick wrote:

This should contain what you are looking for.

How… Who made this?
I believe @deck26 did.

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
oh come on, I was about to do that. I guess I didn't have to do that.
also, turbowarp is blocked for me

Powered by DjangoBB