Piano keys : Anonymous function

Hi, I’m working on the Piano Keys project and I’m stuck on step4 which indicates after third comment inside the function, create an event handler that runs the keyPlay as an event handler when a mousedown event fires on any note .
I wrote my code as below but it didn’t work so I checked the video and figured out that it needs to be anonymous function to assign the event handler function. But I don’t get why it needs to be anonymous function in this case.
Can someone help me?

// The keys and notes variables store the piano keys
const keys = ['c-key', 'd-key', 'e-key', 'f-key', 'g-key', 'a-key', 'b-key', 'high-c-key', 'c-sharp-key', 'd-sharp-key', 'f-sharp-key', 'g-sharp-key', 'a-sharp-key'];
const notes = [];

// Write named functions that change the color of the keys below
const keyPlay = function(event) {
  event.target.style.backgroundColor = 'red';
const keyReturn = function(event) {
  event.target.style.backgroundColor = '';

→// Write a named function with event handler properties
const keyAssignment = function(note) {
  note.onmousedown = keyPlay(event); 
  note.onmouseup = keyReturn(event);

// Write a loop that runs the array elements through the function