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

#1 2009-06-05 09:39:57

raining
Scratcher
Registered: 2009-06-05
Posts: 7

press two buttons at once (combination of keys)

Hi, I'm new to Scratch. I've got a great idea but I'm already struggling.
How can I make it possible to press two keys at once and get an action out of it.
Till now I only could find the possibility of press one key and get an action.
e.g. when 'f' key is pressed
[block]<when[  ]key pressed> [/block]
But I want ; e.g. When 'shift' and 'f' are pressed
Is this possible and how?
I want to make it accessible for key users with short keys (mostly a combination of keys.
Thanks!!!

Offline

 

#2 2009-06-05 10:10:34

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: press two buttons at once (combination of keys)

raining wrote:

Hi, I'm new to Scratch. I've got a great idea but I'm already struggling.
How can I make it possible to press two keys at once and get an action out of it.
Till now I only could find the possibility of press one key and get an action.
e.g. when 'f' key is pressed
[block]<when[  ]key pressed> [/block]
But I want ; e.g. When 'shift' and 'f' are pressed
Is this possible and how?
I want to make it accessible for key users with short keys (mostly a combination of keys.
Thanks!!!

The "shift" key isn't supported in Scratch, but it is very possible to create an action with two keys. Instead of using a script like this:
<when[  ]key pressed> . . .

Use a script like this:
<when green flag clicked>
<forever>
<if><< <key[  ]pressed?> <and> <key[  ]pressed?> >>
so and so . . .

I hope I could help!

Offline

 

#3 2009-06-05 11:26:56

raining
Scratcher
Registered: 2009-06-05
Posts: 7

Re: press two buttons at once (combination of keys)

YEAH!!!! It works!
Hope to show my first Scratch soon.
Thanks, you 're my hero!!!

Offline

 

#4 2009-06-05 11:51:59

raining
Scratcher
Registered: 2009-06-05
Posts: 7

Re: press two buttons at once (combination of keys)

Do you have an example for 3 till 6 key presses at once?
e.g. press D and F and J and K = action

Offline

 

#5 2009-06-05 12:13:38

raining
Scratcher
Registered: 2009-06-05
Posts: 7

Re: press two buttons at once (combination of keys)

Figured it out already.

[block]<when[  ]key pressed>[/block][block]<forever>[/block]
[block]<(  <<<key[  ]pressed?>>  )><<<key[  ]pressed?>  <and> <key[  ]pressed?> >>[/block]

Just place another
[block]<<  <and>  >>[/block]   
over the first upon the second field.

Last edited by raining (2009-06-05 12:15:28)

Offline

 

#6 2009-06-05 12:27:11

raining
Scratcher
Registered: 2009-06-05
Posts: 7

Re: press two buttons at once (combination of keys)

Great!
Another question. So I made a combination 1 (sprite) of 'press  F and J key ' and another combination 2 (sprite) 'press F, J and k key ' . They've got different actions.
If I give it a try they interfere with each other, if a press F, J, and K, both actions start.
I only want to start the action of combination 2, how can I solve this?

Offline

 

#7 2009-06-05 13:15:19

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: press two buttons at once (combination of keys)

if j pressed and f pressed and not k pressed


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#8 2009-06-05 14:23:53

raining
Scratcher
Registered: 2009-06-05
Posts: 7

Re: press two buttons at once (combination of keys)

jeez, 27 times 6, a lot of work!
thx!

Offline

 

#9 2009-06-05 16:10:35

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: press two buttons at once (combination of keys)

I'm glad you've been making progress!  smile

Offline

 

#10 2009-06-12 19:28:51

raining
Scratcher
Registered: 2009-06-05
Posts: 7

Re: press two buttons at once (combination of keys)

Finally some results at http://scratch.mit.edu/users/raining
Discover braille is my first project, still has some trouble with recognizing the right key combination, it will do.
Thanx!

Offline

 

Board footer