/* built with Studio Sketchpad: * https://sketchpad.cc * * observe the evolution of this sketch: * https://studio.sketchpad.cc/sp/pad/view/ro.u8hl3h6juUv/rev.2 * * authors: * GoToLoop * license (unless otherwise specified): * creative commons attribution-share alike 3.0 license. * https://creativecommons.org/licenses/by-sa/3.0/ */ /** * KeyReleased Example * by TFGuy44 (2013/May) * mod GoToLoop * * http://forum.processing.org/topic/help-with-key-released * */ final static byte NUM_KEYS_DOWN = 'Z' - 'A' + 1; final static boolean[] keysDown = new boolean[NUM_KEYS_DOWN]; final static byte GAP = 15, BOLD = 2; final static color BG = #4080A0, FG = #F0F040; void setup() { size(NUM_KEYS_DOWN*GAP - GAP + BOLD*2, 150, P2D); noLoop(); stroke(FG); strokeWeight(BOLD); } void draw() { background(BG); for (int i = 0; i != NUM_KEYS_DOWN; ++i) if (keysDown[i]) line(i*GAP + BOLD, 0, i*GAP + BOLD, height); } void keyPressed() { redraw(); final int k = keyCode; if (k >= 'A' & k <= 'Z') keysDown[k-'A'] = !keysDown[k-'A']; } void keyReleased() { keyPressed(); }