In the p5 javascript library, there's a built-in function {key}
which is the key you press. For example text(${key},200,200)
would display whatever key your pressing on 200,200. If I were to push the {key}
value into an array so the array has the key value you pressed, then console.log()
the value from the array, you'd get: Object {key: "a}. If you were to put this into a text, say you press "A" then you push A into the array. Then you put that into text (Granted A is the only value in the array) text(Array_Of_Text[0],Xposition,Yposition);
The text is simply "Object, Object" So I'd assume I'd have to find the value from the object, which I don't know how to do.
let Text = [];
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
text(Text[0],200,200);
console.log(Text[0])
}
function keyPressed()
{
Text.push({key})
}