# Developing a Robot Into Command Keys Function

Hello Processing friends. I have been learning Processing by myself and doing coding for robots. I am getting a lot of fun. However, I am getting frustrated because I has not been able to turn the code from mouse functions into command keys function.

loat xVal = 50;
float yVal = 1100;
int myBodyHeight = 1000;
int myBodyWidth = 500;
int myNeckHeight = 200;
// Our text included this without using it…
float easingVal = 0.1;

void setup() {
size(1200,1200);
ellipseMode(RADIUS); // draw ellipse from top
}

void draw() {
strokeWeight(90);

background(0, 100, 200); // Blue

translate(mouseX, yVal); // Move all to myNewX

// Toggle the scale of everything
if (mousePressed) {
scale(0.6);
} else {
scale(0.4);
}

// Body
noStroke();
fill(255, 204, 0); // Orange
ellipse(0, -99, 99,99); // The leg
fill(0); // Black
// Calculate the rect for the body relative to the 0,0 center
rect(-myBodyWidth/2, -myBodyHeight, myBodyWidth, myBodyHeight-99);

// Neck
// Set the y location of the neck relative to the size of the
// other components
stroke(255); // White
line(30, -myBodyHeight, 10, myNeckY);

// Hair
pushMatrix(); // Isolate translation and rotation
// translate from the top of the head
translate(44, myNeckY);
// set myAngle to 1/90th of half way around
float myAngle = -PI/444.0;
for (int i = 0; i <= 444; i++) {
// do these statement 99 times, rotating a bit each time
line(444, 0, 0, 0);
rotate(myAngle);
}
popMatrix(); // end isolation of translate and rotate

noStroke();
fill(0); // Red
// White eyeball
fill(255); // White
int eyeSize = 200;
ellipse(12, myNeckY-12, eyeSize, eyeSize);
// Green Iris
fill(0, 200, 200); // Green
ellipse(24, myNeckY-9, eyeSize0.66,eyeSize0.66);
// Black pupil
fill(0); // Black
ellipse(20, myNeckY-2, eyeSize0.33,eyeSize0.33);

I want to ask you for a favor. Could you please tell me how to turn this code from mouse function into commandkeys? Do I have to change floats into bolans? I want to be able to build the same robot, but with command keys functions.

Thank you so much.

Sincerely
Steve

Please don’t copy the same question into multiple posts.

Conversation continued here: Developing a coding to move on a robot