let opac = 128;
function
setup() {
createCanvas(700, 200);
background(0, 128, 0, opac);
textSize(22);
text(
"Press the left and right arrow"
+
" keys to change the opacity"
+
" of the color."
, 10, 20);
}
function
keyPressed() {
clear();
textSize(50);
text(
"Pressing: "
+ key, 100, 150);
if
(key ==
"ArrowLeft"
&& opac > 0)
opac -= 20;
else
if
(key ==
"ArrowRight"
&& opac < 255)
opac += 20;
background(0, 128, 0, opac);
textSize(22);
text(
"Press the left and right arrow"
+
" keys to change the opacity"
+
" of the color."
, 10, 20);
}