xxxxxxxxxx
24
let key_map = [];
function setup() {
createCanvas(400, 400);
}
function draw() { // game update
background(200)
handleKeys();
}
function handleKeys() { // handles game updates depending on the key's that are pressed
if (key_map['k']) // if the key 'k' is pressed we show the message
text("k is held down", width/2, height/2);
}
function keyPressed() { // handles key press
key_map[key] = true;
}
function keyReleased() { // handles key release
key_map[key] = false;
}