Sprite not moving on key press

I am trying to create an endless runner game from scratch using JavaScript, and I am currently in the process of making the character jump. However, when I press the spacebar, my character does not move up, but instead just stays in one place. I have pasted my code below:

let ctx = document.querySelector("canvas").getContext("2d");

// Screen size

ctx.canvas.height = 512;
ctx.canvas.width = 512;

// Images

let bg = new Image; // Background
bg.src = "./Background.png";
bg.onload = function() {
  ctx.drawImage(bg, 0, 0);
};

let fl = new Image; // Floor
fl.src = "./Floor.png";
fl.onload = function() {
  ctx.drawImage(fl, 0, 384);
  ctx.drawImage(fl, 128, 384);
  ctx.drawImage(fl, 256, 384);
  ctx.drawImage(fl, 384, 384);
};

let pl = new Image; // Player
pl.src = "./Idle.png";
pl.onload = function() {
  ctx.drawImage(pl, 0, 256);
};

// Movement

let UP = false;

document.onkeydown = function(e) {
  if (e.keyCode == 32) UP = true;
};

document.onkeyup = function(e) {
  if (e.keyCode == 32) UP = false;
};

setInterval(update, 10);

function update() {
  ctx.clearRect(0, 0, canvas.width, canvas.height); // Erase previous positions

  if (UP) {
    pl.onload = function() {
      ctx.drawImage(pl, 0, 256 += 1); // Move player up
    };
  };
};

Answer

I fixed it with some help from Rojo.

let ctx = document.querySelector("canvas").getContext("2d");

// Screen size
ctx.canvas.height = 512;
ctx.canvas.width = 512;

// Images
let bg = new Image;
bg.src = "./Background.png";

let fl = new Image;
fl.src = "./Floor.png";

let pl = new Image;
pl.src = "./Idle.png";
let y = 256;
pl.onload = function() {
  ctx.drawImage(pl, 0, y);
};

let UP = false;

document.onkeydown = function(e) {
  if (e.keyCode == 32) UP = true;
};

document.onkeyup = function(e) {
  if (e.keyCode == 32) UP = false;
};

function update() {
  ctx.clearRect(0, 0, 512, 512);

  ctx.drawImage(bg, 0, 0);

  ctx.drawImage(fl, 0, 384);
  ctx.drawImage(fl, 128, 384);
  ctx.drawImage(fl, 256, 384);
  ctx.drawImage(fl, 384, 384);

  if (UP) {
    ctx.drawImage(pl, 0, y -= 1);
  } else {
    ctx.drawImage(pl, 0, y);
  };
};

setInterval(update, 10);