Discuss Scratch

Gamer_Logan819
Scratcher
1000+ posts

What key is pressed returner

Basically, it’s like

<key [any v] pressed?>

but it returns the key pressed

So it would look something like:

<key pressed? :: sensing >

and would work in a script like:


if < <key pressed? :: sensing> = [b] :: operator >then
say [Hello!]
end

the sprite would say “Hello!” when b key is pressed.

Last edited by Gamer_Logan819 (April 20, 2022 17:14:16)


The forum boogeymen are out to get you

ScolderCreations
Scratcher
1000+ posts

What key is pressed returner

So… what would it return when you press two buttons at the same time?

Gamer_Logan819
Scratcher
1000+ posts

What key is pressed returner

ScolderCreations wrote:

So… what would it return when you press two buttons at the same time?

It is impossible to press 2 keys at the exact same time, down to the zeptosecond. The first clicked would return. If a robot was able to click them at the EXACT same time, it would return “NaN”

The forum boogeymen are out to get you

Jbear_
Scratcher
1000+ posts

What key is pressed returner

when [b v] key pressed
Say [hello]

My best project ever. Please Rate And suggest.

(Unrelated)
in memory of Celly.
Gamer_Logan819
Scratcher
1000+ posts

What key is pressed returner

Jbear_ wrote:

when [b v] key pressed
Say [hello]


That is not going to help, I would still have to do

Jbear_ wrote:

when [b v] key pressed
Say [hello]

Jbear_ wrote:

when [c v] key pressed
Say [hello]
when [d v] key pressed
Say [hello]


and so on.

What I need the block I suggested for is
(join (typed letters) <key pressed? :: sensing>)

The forum boogeymen are out to get you

Jbear_
Scratcher
1000+ posts

What key is pressed returner

Gamer_Logan819 wrote:

Jbear_ wrote:

when [b v] key pressed
Say [hello]


That is not going to help, I would still have to do

Jbear_ wrote:

when [b v] key pressed
Say [hello]

Jbear_ wrote:

when [c v] key pressed
Say [hello]
when [d v] key pressed
Say [hello]


and so on.

What I need the block I suggested for is
(join (typed letters) <key pressed? :: sensing>)
The Boolean blocks dont go into reporter blocks….

My best project ever. Please Rate And suggest.

(Unrelated)
in memory of Celly.
Jbear_
Scratcher
1000+ posts

What key is pressed returner

when green flag clicked
forever
if <<key [a v] pressed?> or <key [b v] pressed?>> then
Say [hello!]
end
end

Last edited by Jbear_ (April 20, 2022 18:22:34)


My best project ever. Please Rate And suggest.

(Unrelated)
in memory of Celly.
Gamer_Logan819
Scratcher
1000+ posts

What key is pressed returner

Jbear_ wrote:

when green flag clicked
forever
if <<key [a v] pressed?> or <key [b v] pressed?>> then
Say [hello!]
end
end


But I’m making a typing system, and I need all of the letters, which would be both time consuming and memory consuming (scratch had 50mb limit)

The forum boogeymen are out to get you

AmazingMech2418
Scratcher
1000+ posts

What key is pressed returner

If anything, it should be a list of all keys held down at that moment, perhaps including individual modifiers too. (for example, typing “!” would return shift, 1, and !)

I'm a programmer, ethical hacker, and space nerd!

Last edited by Neil Armstrong (July 20, 1969 20:17:00)












sam
Silicobra
New to Scratch
100+ posts

What key is pressed returner

Gamer_Logan819
Scratcher
1000+ posts

What key is pressed returner

AmazingMech2418 wrote:

If anything, it should be a list of all keys held down at that moment, perhaps including individual modifiers too. (for example, typing “!” would return shift, 1, and !)


I was thinking of that, but that just seems sort of complicated. I like it though.

The forum boogeymen are out to get you

IndexErrorException
Scratcher
500+ posts

What key is pressed returner

Simple answer to when there is a two buttons down at the same time. Return the most latest button pressed, just like how most coding languages do it.
AmazingMech2418
Scratcher
1000+ posts

What key is pressed returner

XxhackerlolxX wrote:

Simple answer to when there is a two buttons down at the same time. Return the most latest button pressed, just like how most coding languages do it.
Most languages don't just have a “key pressed” function. XD They usually have key events that are triggered when a key is pressed which then allows you to handle that specific event for that specific key.

I'm a programmer, ethical hacker, and space nerd!

Last edited by Neil Armstrong (July 20, 1969 20:17:00)












sam
Wifi_Spider
Scratcher
100+ posts

What key is pressed returner

it should be a variable if it returns like that

Generation 6: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.
hi im Wifi_Spider and this is my siggy here are some links
My profile
My first project
my scratch stats
not a rickroll
ok so im gonna make this intresting
i have line in me
im on the floor!
im gonna fall!
im bold
hehe also defence against evil kumquat
when green flag clicked
forever
if <kumquat is near?> then
repeat until <not <kumquat is near?>>
defeat kumquat
end


else
relax
end
end
sizes:
BIG

small

Emojis:







im gonna stop so i dont slow down the server

IndexErrorException
Scratcher
500+ posts

What key is pressed returner

AmazingMech2418 wrote:

XxhackerlolxX wrote:

Simple answer to when there is a two buttons down at the same time. Return the most latest button pressed, just like how most coding languages do it.
Most languages don't just have a “key pressed” function. XD They usually have key events that are triggered when a key is pressed which then allows you to handle that specific event for that specific key.

XD? Yes, I meant a event trigger but I also know python library(forgot which one) that has the current key pressed, and luaU which has a get function which returns an array of pressed keys. Mr. Space Nerd.
Wifi_Spider
Scratcher
100+ posts

What key is pressed returner

i just figured some thing out
<key [any v] pressed?>
that returns with the key pressed but its just is like thats a key so im gonna activate

Generation 6: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.
hi im Wifi_Spider and this is my siggy here are some links
My profile
My first project
my scratch stats
not a rickroll
ok so im gonna make this intresting
i have line in me
im on the floor!
im gonna fall!
im bold
hehe also defence against evil kumquat
when green flag clicked
forever
if <kumquat is near?> then
repeat until <not <kumquat is near?>>
defeat kumquat
end


else
relax
end
end
sizes:
BIG

small

Emojis:







im gonna stop so i dont slow down the server

Wifi_Spider
Scratcher
100+ posts

What key is pressed returner

this is the script
when green flag clicked
forever
if <<key [any v] pressed?>=(1)> then
say [hello]
end
end
but with the block the script looks like this
when green flag clicked
forever
if <<key pressed?::sensing>=(1)> then
say [hello]
end
end
and they do the exact same thing go ahead try it yourself (edited for more realistic key pressed block)

Last edited by Wifi_Spider (April 20, 2022 21:29:15)


Generation 6: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.
hi im Wifi_Spider and this is my siggy here are some links
My profile
My first project
my scratch stats
not a rickroll
ok so im gonna make this intresting
i have line in me
im on the floor!
im gonna fall!
im bold
hehe also defence against evil kumquat
when green flag clicked
forever
if <kumquat is near?> then
repeat until <not <kumquat is near?>>
defeat kumquat
end


else
relax
end
end
sizes:
BIG

small

Emojis:







im gonna stop so i dont slow down the server

historical_supa
Scratcher
1000+ posts

What key is pressed returner

It should be
(key pressed :: sensing)

Last edited by historical_supa (April 20, 2022 23:08:32)


i love life
IndexErrorException
Scratcher
500+ posts

What key is pressed returner


Simple workaround to detect every letter,number and other things like commas and dots. No support for backspace tho
k0d3rrr
Scratcher
1000+ posts

What key is pressed returner

For those who cannot view the workaround above because the image is being hosted on CubeUpload:


Animated button created by me


Despite what my About section says, I have been using Scratch before 2019. 2019 was the year that I first joined Scratch.

Powered by DjangoBB