Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h1>WEBMIDI.js Demo</h1>
<p><em>(detecting devices)</em></p>


                html {
  max-width: 70ch;
  padding: 3em 1em;
  margin: auto;
  line-height: 1.75;
  font-size: 1.25em;


                // Enable WebMidi.js and trigger the onEnabled() function when ready

// Function triggered when WebMidi.js is ready
function onEnabled() {
	// Remove that loading message

	// Display available MIDI input devices
	if (WebMidi.inputs.length < 1) {
		document.body.innerHTML += "<p>No device(s) detected</p>";
	} else {
		WebMidi.inputs.forEach((device, index) => {
			document.body.innerHTML += `<p>${index}: ${}</p>`;

	const mySynth = WebMidi.inputs[0];
	// const mySynth = WebMidi.getInputByName("TYPE NAME HERE!")

	// Notes
	mySynth.channels[1].addListener("noteon", (e) => {
		document.body.innerHTML += `${}`;
	// Touchpads, (unless CC active)
	mySynth.channels[10].addListener("noteon", e => {
	// Knobs (and touchpads when CC active)
	mySynth.addListener("controlchange", e => {
	  console.log(`Received 'controlchange' message.`, e.value);
	}, {channels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]});

function onError(err) {
	document.querySelector('p').innerHTML  = `❌ ${err}<br />👉 Visit this demo directly on CodePen (not through an iframe/embed)`;