Piano keys project (task 4 & 5)

function eventAssignment(note) {
  note.onmousedown = function()  {
  note.onmouseup = function() {

To get the result of these tasks, in walkthrough they used above code.

function eventAssignment(note) {

note.addEventListener = ('mousedown', keyPlay);
note.addEventListener = ('mouseup', keyReturn);

i tried to used above code, but it is not working, why ??

Hi @betaslayer45561
I don’t fully understand the question. The first block works, just the second doesn’t?
The first looks fine, if it doesn’t work, we’d need to see some more code.
The second block doesn’t have the correct syntax. That’s how you’d write it:

note.addEventListener('mousedown', keyPlay);

hi @mirja_t
The first code is working fine, but when i tried to use second code instead of first one, it doesn’t work. so why the second code (addEventListener) is not working ?

Simply because the syntax isn’t correct. Compare your code with my line, see the difference?

ohhh, that was stupid mistake :pensive:

Thanks for your quick responses :+1:

1 Like