noteIsDown()#
functionoav-p5noteIsDown(n)
True while the key n (a MIDI number or a name like 'C4') is held down.
The MIDI version of keyIsDown(). noteIsDown('C4') is the same as noteIsDown(60): C4 is middle C. A name that is not a note ('H4', 'C-2') stops the sketch with a one-line card saying how to write it.
Parameters
| Name | Type | Description |
|---|---|---|
n | Number | String | The key: a MIDI number (60) or a note name ('C4', 'c#4', 'Db3'). |
Returns
Boolean True if that key is down right now.
Examples
function setup() {
createCanvas(400, 300);
}
function draw() {
background(20);
fill(noteIsDown('C4') ? color(255, 211, 107) : 80);
circle(width / 2, height / 2, 140); // lights up while middle C is held
}Related
noteIsPressedTrue while at least one key is held down.noteNumber()Turns a note name like'C4'into its MIDI number, 0 to 127.notePressed()You define this function; oav-p5 calls it each time a key (or a pad) goes down.