If you don’t want to directly use the Web MIDI API, you can use
WEBMIDI.js makes it easy to interact with MIDI instruments directly from a web browser or from Node.js. It simplifies the control of physical or virtual MIDI instruments with user-friendly functions such as
sendControlChange(). It also allows reacting to inbound MIDI messages by adding listeners for events such as
Works like a charm. Initialize it, and start listening for events.
In the browser you can include a self-registering script to get it. ESM and CJS flavors are also available.