We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I've just started p5 programming and I'm really into it , but I can't figure out how to move an object with direction arrows.
    function setup(){
        createCanvas(1250,1000);
        bug = new obj();
    }
    function draw(){
        background(50,89,100);
        bug.display();
        stroke(255);
        if(keycode == LEFT_ARROW)
            bug.move(-this.speed,0);
        if(keycode == RIGHT_ARROW)
            bug.move(this.speed,0);
        if(keycode == UP_ARROW)
            bug.move(0,-this.speed);
        if(keycode == DOWN_ARROW)
            bug.move(0,this.speed);
    }
`function obj(){
    this.y=random(height);
    this.x=random(width);
    this.diameter=random(10,30);
    this.speed=10;
`
`this.move = function(posx,posy) {
        this.x+=posx;
        this.y+=posy;
  };
`
    `this.display = function(){
        ellipse(this.x,this.y,this.diameter,this.diameter);
    }
};
`
That's my code , but my object seems to be stuck in the canvas , not moving at all.
Answers
https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
http://p5js.org/reference/#/p5/keyIsDown
https://forum.Processing.org/two/discussions/tagged?Tag=keyisdown()
Oh great. I needed this KeyIsDown a while ago. I kept confusing it with KeIsPressed.