# Developing a Robot Into Command Keys Function

**URL:** https://discourse.processing.org/t/developing-a-robot-into-command-keys-function/5273
**Category:** Coding Questions
**Created:** [November 6, 2018, 7:28pm UTC](https://discourse.processing.org/t/developing-a-robot-into-command-keys-function/5273 "2018-11-06T19:28:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![SteveTombs92](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@SteveTombs92](https://discourse.processing.org/u/SteveTombs92)
#### Post date: [November 6, 2018, 7:28pm UTC](https://discourse.processing.org/t/developing-a-robot-into-command-keys-function/5273/1 "2018-11-06T19:28:22Z")

</div>

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 myHeadRadius = 300;  
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  
float myNeckY = -1 \* (myBodyHeight + myNeckHeight + myHeadRadius);  
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

// Head  
noStroke();  
// Red head circle  
fill(0); // Red  
ellipse(12, myNeckY, myHeadRadius, myHeadRadius);  
// 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, eyeSize_0.66,eyeSize_0.66);  
// Black pupil  
fill(0); // Black  
ellipse(20, myNeckY-2, eyeSize_0.33,eyeSize_0.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

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [November 6, 2018, 7:50pm UTC](https://discourse.processing.org/t/developing-a-robot-into-command-keys-function/5273/2 "2018-11-06T19:50:00Z")

</div>



---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [November 6, 2018, 7:52pm UTC](https://discourse.processing.org/t/developing-a-robot-into-command-keys-function/5273/3 "2018-11-06T19:52:43Z")

</div>

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

Conversation continued here: [Developing a coding to move on a robot](https://discourse.processing.org/t/developing-a-coding-to-move-on-a-robot/5272)
