This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-21 10:08:46

awesomeprojects42
Scratcher
Registered: 2011-07-03
Posts: 59

Key Sensor

There could be a block that senses whether you hold down that key or press it


http://i54.tinypic.com/308ea90.gifclick the triforce

Offline

 

#2 2011-09-21 18:58:02

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Key Sensor

There already is one - the "key pressed" hat block.  smile

http://wiki.scratch.mit.edu/images/When_Key_Pressed.png


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2011-09-21 23:37:57

awesomeprojects42
Scratcher
Registered: 2011-07-03
Posts: 59

Re: Key Sensor

that's not wat i mean, i maen a script that can tell if its pressed or if it's held down


http://i54.tinypic.com/308ea90.gifclick the triforce

Offline

 

#4 2011-09-22 00:01:24

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Key Sensor

There is one, it's under sensing.

http://wiki.scratch.mit.edu/images/Key_%28%29_Pressed%3F.png
It looks like that.

More information can be found on the wiki here.

Offline

 

#5 2011-09-22 09:57:28

awesomeprojects42
Scratcher
Registered: 2011-07-03
Posts: 59

Re: Key Sensor

no

Last edited by awesomeprojects42 (2011-09-22 09:59:03)


http://i54.tinypic.com/308ea90.gifclick the triforce

Offline

 

#6 2011-09-22 19:32:25

ihaveamac
Scratcher
Registered: 2007-09-22
Posts: 1000+

Re: Key Sensor

awesomeprojects42 wrote:

no

...Then what do you want? Both blocks do exactly what you described.


~ihaveamac - visit ihaveamac.net

Offline

 

#7 2011-09-22 20:27:00

Sausagefanclub
Scratcher
Registered: 2011-08-31
Posts: 500+

Re: Key Sensor

I think he means a block that activates if a key is held down for a certain amount of time, like this:

<key _ is held down for _ seconds>


http://sausagepages1185.weebly.com/uploads/1/4/1/5/14153465/446452.png?525

Offline

 

#8 2011-09-23 17:06:26

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: Key Sensor

well, I know a peice of code that would do that...:
if <key [   v] pressed> then
wait () secs
if <key [(same key as starting key in script)v] pressed then
--code here


I'm back.
Maybe.

Offline

 

#9 2011-09-23 18:41:30

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Key Sensor

No

Well, then first you must help us define how long a press is and how long a hold is.

Last edited by kayybee (2011-09-23 18:41:46)

Offline

 

#10 2011-09-23 20:04:44

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: Key Sensor

Code:

If <key [ v] pressed>:
    repeat until [count] = 5
        wait 1 second
        change [count] by 1
    if ([count]=5)
        broadcast [keypressed]
    else 
        set [count] to 0
        broadcast [failure]

When Scratch 2.0 is released you can compile this into a single block!  wink


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

Board footer