Online Sequencer Forums

Full Version: Hold CTRL for Multi-select
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
A really basic yet missing feature is the ability to hold CTRL (or Command for Macs) to select multiple notes with ease. 

Below is a simple yet working implementation:

Code:
// Tracks control key state
var ctrlDown = false;

// Override existing onNoteClick function
function onNoteClick(event) {
   var element = document.elementFromPoint(event.clientX, event.clientY);
   if (element != undefined && element.noteData != undefined && !instrumentLock[element.noteData.instrument]) {
       var note = element.noteData;
       if (note.selected == false) {

            // If control is down, don't clear the selection
           if(!ctrlDown)
               clearSelection();
           select(note);
       }
       dragSelection();
       playNote(note.instrument, note.type, note.length);
       window.top.confirmExit = true;
       return clickedNote = true;
   } else {
        // Don't clear the selection in-case the user accidentally misses the note
       if(!ctrlDown)
           clearSelection();
       return clickedNote = false;
   }
}

// Event listeners for the control key
window.addEventListener("keydown", function(event) {
   if (event.keyCode == 17) {
       ctrlDown = true;
   }
   
}, false);

window.addEventListener("keyup", function(event) {
   if (event.keyCode == 17) {
       ctrlDown = false;
   }
}, false);