MidiKeyboardComponent Key Hold

the MidiKeyboardComponent works as aspected, however I would like to implement the key hold feature. When a key is pressed (trough the mouse) it should be stay down until the user press again to release the note.
I can’t figure out to achieve this behaviour.
Thanks in advance for the help, Greetings.

I’ve solved by

  1. subclass the MidiKeyboardComponent

  2. keep a ptr of MidiKeyboardState

  3. override these methods
    void setHoldKeys(bool hold)
    holdKeys = hold;

    void mouseDown(const MouseEvent& e) override {

     if (!holdKeys)
         int noteNum = getNoteAtPosition(e.getPosition());
         float veloc = __scale(e.x, 0, getWidth(), 0., 1., 1.);
         int channel = getMidiChannel();
         bool state = state_alias->isNoteOn(channel, noteNum);
         if (state) state_alias->noteOff(channel, noteNum, 0);
         else state_alias->noteOn(channel, noteNum, veloc);


    void mouseDrag (const MouseEvent& e) override
    if (!holdKeys) MidiKeyboardComponent::mouseDrag(e);