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

#51 2010-09-13 11:44:47

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Can anyone make a (key pressed) block?

shadow_7283 wrote:

LOL it was so easy....

keyPressed
    "Answer the currently pressed key."

    self keyNames do: [:ch |
        (self keyPressed: ch) ifTrue: [^ ch]].
    ^ ''.

Block spec:

('key pressed' #r #keyPressed)

Or for those who use the source (Go you!):

('key pressed'                      #r      keyPressed)

The code that works is:
            "Answer the currently pressed key."

            self keyNames do: [:ch |
                       (self keyPressed: ch) ifTrue: [^ ch] ifFalse: [^ none]].
I am not entirely sure.  hmm

Last edited by rdococ (2010-09-13 11:45:50)

Offline

 

#52 2010-09-13 13:30:31

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Can anyone make a (key pressed) block?

rdococ wrote:

shadow_7283 wrote:

LOL it was so easy....

keyPressed
    "Answer the currently pressed key."

    self keyNames do: [:ch |
        (self keyPressed: ch) ifTrue: [^ ch]].
    ^ ''.

Block spec:

('key pressed' #r #keyPressed)

Or for those who use the source (Go you!):

('key pressed'                      #r      keyPressed)

The code that works is:
            "Answer the currently pressed key."

            self keyNames do: [:ch |
                       (self keyPressed: ch) ifTrue: [^ ch] ifFalse: [^ none]].
I am not entirely sure.  hmm

that looks good to me. i havent inspected it really though.

Offline

 

#53 2010-09-13 14:07:47

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Can anyone make a (key pressed) block?

"Answer the currently pressed key."

            self keyNames do: [:ch |
                       (self keyPressed: ch) ifTrue: [^ ch]].
            ^  'none'


/* No comment */

Offline

 

#54 2010-09-13 16:01:46

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Can anyone make a (key pressed) block?

rdococ wrote:

shadow_7283 wrote:

LOL it was so easy....

keyPressed
    "Answer the currently pressed key."

    self keyNames do: [:ch |
        (self keyPressed: ch) ifTrue: [^ ch]].
    ^ ''.

Block spec:

('key pressed' #r #keyPressed)

Or for those who use the source (Go you!):

('key pressed'                      #r      keyPressed)

The code that works is:
            "Answer the currently pressed key."

            self keyNames do: [:ch |
                       (self keyPressed: ch) ifTrue: [^ ch] ifFalse: [^ none]].
I am not entirely sure.  hmm

You do know that you just falsely quoted Shadow writing what I wrote? This is not Shadow's post.
And that won't work. This thread is already solved, so stop posting solutions that look exactly like mine.

Last edited by nXIII (2010-09-13 16:02:52)


nXIII

Offline

 

#55 2010-09-13 17:09:17

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

Re: Can anyone make a (key pressed) block?

tongue  You made nXIII angry.

Offline

 

#56 2010-09-13 17:24:23

zorket
Scratcher
Registered: 2010-05-25
Posts: 500+

Re: Can anyone make a (key pressed) block?

nXIII wrote:

LOL it was so easy....

keyPressed
    "Answer the currently pressed key."

    self keyNames do: [:ch |
        (self keyPressed: ch) ifTrue: [^ ch]].
    ^ ''.

Block spec:

('key pressed' #r #keyPressed)

Or for those who use the source (Go you!):

('key pressed'                    r    keyPressed)

Won't work


Marzipan11 must learn to not spoil

Offline

 

#57 2010-09-13 17:26:57

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

Re: Can anyone make a (key pressed) block?

zorket wrote:

nXIII wrote:

LOL it was so easy....

keyPressed
    "Answer the currently pressed key."

    self keyNames do: [:ch |
        (self keyPressed: ch) ifTrue: [^ ch]].
    ^ ''.

Block spec:

('key pressed' #r #keyPressed)

Or for those who use the source (Go you!):

('key pressed'                    r    keyPressed)

Won't work

It does work.

Offline

 

#58 2010-09-13 17:51:37

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Can anyone make a (key pressed) block?

shadow_7283 wrote:

zorket wrote:

nXIII wrote:

LOL it was so easy....

keyPressed
    "Answer the currently pressed key."

    self keyNames do: [:ch |
        (self keyPressed: ch) ifTrue: [^ ch]].
    ^ ''.

Block spec:

('key pressed' #r #keyPressed)

Or for those who use the source (Go you!):

Won't work

It does work.

He probably just didn't use copy-paste and typed it wrong  roll


nXIII

Offline

 

#59 2010-09-13 20:34:04

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

Re: Can anyone make a (key pressed) block?

Or used "Control- v"

Offline

 

#60 2010-09-13 20:37:45

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Can anyone make a (key pressed) block?

shadow_7283 wrote:

Or used "Control- v"

lol


nXIII

Offline

 

#61 2010-09-14 16:32:42

zorket
Scratcher
Registered: 2010-05-25
Posts: 500+

Re: Can anyone make a (key pressed) block?

bbbeb wrote:

zorket wrote:

bbbeb wrote:

OMGBBQNECROPOST  tongue 
Dont revive old posts just to say:
cool.

I just like the topic slightly  hmm


DON'T DO THAT!  mad

roll
REPEAT:
OMGWTHBBQNECROPOSTER  tongue   tongue   tongue   tongue   sad   sad   sad   sad

BE QUIET!  mad
_______________
This is my 100th post :p

Last edited by zorket (2010-09-14 16:33:29)


Marzipan11 must learn to not spoil

Offline

 

#62 2010-09-14 16:54:49

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

Re: Can anyone make a (key pressed) block?

cool.  This is about my 580th post

The <key pressed> block doesnt work for me


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

Offline

 

#63 2010-09-14 17:09:38

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

Re: Can anyone make a (key pressed) block?

It's actually (key pressed), and if you used shift-click-r you can't do the same thing nXIII did.

Offline

 

#64 2010-09-14 21:34:59

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Can anyone make a (key pressed) block?

zorket wrote:

bbbeb wrote:

zorket wrote:

I just like the topic slightly  hmm


DON'T DO THAT!  mad

roll
REPEAT:
OMGWTHBBQNECROPOSTER  tongue   tongue   tongue   tongue   sad   sad   sad   sad

BE QUIET!  mad
_______________
This is my 100th post :p

This is my 277th post!

_______________
This topic needs to be closed, it is already solved...

Last edited by bbbeb (2010-09-14 21:35:12)


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#65 2010-09-14 22:42:29

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

Re: Can anyone make a (key pressed) block?

No it doesn't. It needs to be left open in case other people have questions about it.

It's not my fault you guys brought it up again.

Offline

 

#66 2010-09-15 19:09:34

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Can anyone make a (key pressed) block?

shadow_7283 wrote:

No it doesn't. It needs to be left open in case other people have questions about it.

It's not my fault you guys brought it up again.

Yes. It. Does.
NXIII posted the code... solving the issue...  what else is there to explain?


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#67 2010-09-16 16:30:32

1stCorinthians
Scratcher
Registered: 2009-06-14
Posts: 52

Re: Can anyone make a (key pressed) block?

Oh, really? It's already solved? Well, I wasn't aware of that. Bye It looks like i wont give any helpful advice then

Last edited by 1stCorinthians (2010-09-16 16:33:59)

Offline

 

Board footer