I am trying to make an app with piano keys, and when you click on the keys, a note plays. I want to change the duration of the note based on how long the key is pressed, so timing from mousePressed() to mouseReleased(). I have the math, but I don't know how to use this as the duration of the current note, because the duration is already defined when the note starts, so it just uses the length that the previous key was clicked. Is there a way to have the length of the note defined by the length that the piano key is pressed?