nick34992
5/1/2016 - 2:35 PM

Test Keys. Using Processing.js Library

Test Keys. Using Processing.js Library

// Based on:
// 'keyCode | ProcessingJS'
// https://www.khanacademy.org/computer-programming/keycode/939888407
// Codepen
// http://codepen.io/Indiessance/pen/vGQXGr

void setup () {
  size(400, 300); 
}

void draw() {
    background(0);
    textSize(25);
    if (keyCode == DOWN) {
        fill(255, 0, 0);
        text("DOWN", 150, 150);
    } else if (keyCode == UP) {
        fill(0, 0, 255);
        text("UP", 150, 150);
    } else if (keyCode == RIGHT) {
        fill(0, 255, 0);
        text("RIGHT", 150, 150);
    } else if (keyCode == LEFT) {
        fill(255, 255, 0);
        text("LEFT", 150, 150);
    } else if (keyCode == ALT) {
        fill(0, 255, 255);
        text("ALT", 150, 150);
    } else if (keyCode == CONTROL) {
        fill(255, 0, 255);
        text("CONTROL", 150, 150);
    } else if (keyCode == SHIFT) {
        fill(127, 127, 127);
        text("SHIFT", 150, 150);
    }
    ellipse(100,100,100,100);
    fill(255);
    text("Test Keys:", 50, 200);
    text("UP, DOWN, LEFT, RIGHT", 50, 230);
    text("ALT, CONTROL, SHIFT", 50, 260);
};