xxxxxxxxxx
40
// An example of showing data coming off the keyboard
//
// Try using this with the MakeCode + CPX program: https://makecode.com/_aty8LPKr7Tfd
//
// By Jon Froehlich
// @jonfroehlich
// http://makeabilitylab.io
//
let textToShow = "Click here, type, and click the ENTER key";
let keyboardStr = "";
function setup() {
createCanvas(600, 400);
textSize(22);
}
function draw() {
background(190);
textAlign(CENTER);
noStroke();
fill(0);
text(textToShow, width/2, height/2);
}
function keyTyped(){
if (keyCode != ENTER) {
keyboardStr += key;
}
}
function keyPressed() {
print(key);
if (keyCode == ENTER) {
textToShow = keyboardStr;
keyboardStr = "";
}
}