Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Checking Whether a Key is Pressed - issue
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dan Salmonsen  
View profile  
 More options Jun 5 2012, 7:25 pm
From: Dan Salmonsen <d...@salmonsen.org>
Date: Tue, 5 Jun 2012 16:25:59 -0700
Local: Tues, Jun 5 2012 7:25 pm
Subject: Checking Whether a Key is Pressed - issue
In this tutorial example, the script will not draw when mouse is move
for the first time while the 'a' key is pressed.

http://paperjs.org/tutorials/interaction/keyboard-interaction/#is-tha...

Is there a reason or work around for this?

Thanks,
Dan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Puckey  
View profile  
 More options Jun 6 2012, 6:07 am
From: Jonathan Puckey <m...@jonathanpuckey.com>
Date: Wed, 6 Jun 2012 12:07:37 +0200
Local: Wed, Jun 6 2012 6:07 am
Subject: Re: Checking Whether a Key is Pressed - issue
The solution would be to check if the path has only 1 segment and then add an extra one if it has:

var path;
function onMouseDown(event) {
    path = new Path();
    path.strokeColor = 'black';
    path.add(event.point);

}

function onMouseDrag(event) {
    if(Key.isDown('a')) {
        if (path.segments.length == 1)
            path.add(event.point);
        // If the 'a' key is down, change the point of
        // the last segment to the position of the mouse:
        path.lastSegment.point = event.point;
    } else {
        // If the a key is not down, add a segment
        // to the path at the position of the mouse:
        path.add(event.point);
    }

}

On Jun 6, 2012, at 1:25 AM, Dan Salmonsen wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
dansalmo  
View profile  
 More options Jun 9 2012, 12:34 am
From: dansalmo <salmo...@googlemail.com>
Date: Fri, 8 Jun 2012 21:34:50 -0700 (PDT)
Local: Sat, Jun 9 2012 12:34 am
Subject: Re: Checking Whether a Key is Pressed - issue
Jonathan,

Thank you for the explanation and working example.

On Jun 6, 3:07 am, Jonathan Puckey <m...@jonathanpuckey.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »