MIDIPort: statechange event - Web APIs | MDN
Syntax
Use the event name in methods like addEventListener(), or set an event handler property.
js
addEventListener("statechange", (event) => { })
onstatechange = (event) => { }
Event type
A MIDIConnectionEvent. Inherits from Event.
Event properties
MIDIConnectionEvent.portRead only-
Returns a reference to a
MIDIPortinstance for a port that has been connected or disconnected.
Example
In the following example the current MIDIPort.state is logged each time it changes.
js
port.onstatechange = (event) => {
console.log(port.state);
};
Specifications
| Specification |
|---|
| Web MIDI API # dom-midiport-onstatechange |