Referencing functions within object properties does not work

Your syntax error is one issue, but you should have gotten an err msg on that …

@GoToLoop’s example works just fine, also this fix below of your original works just fine …

const keys = {
  ArrowUp: action1
};

function setup() {
  background(100);
}

function action1() {
  console.log(keys[key]);
}


function keyPressed() {
  if (keys[key] !== undefined) {
    keys[key]();
  }
}
3 Likes