-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbasic-with-umd.html
32 lines (27 loc) · 1.03 KB
/
basic-with-umd.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Launchpad WebMIDI test</title>
</head>
<body>
<h1>Basic demo of <i>launchpad-webmidi</i> using UMD.</h1>
<p>Launchpad status: <span id='status'></span></p>
<script src='../dist/launchpad-webmidi.umd.js'></script>
<script>
document.querySelector('#status').innerHTML = 'Not connected';
let pad = new Launchpad();
pad.connect().then(() => { // Auto-detect Launchpad
document.querySelector('#status').innerHTML = 'Connected';
pad.reset(2); // Make Launchpad glow yellow
pad.on('key', k => {
console.log(`Key ${k.x},${k.y} down: ${k.pressed}`, k);
// Make button red while pressed, green after pressing
pad.col(k.pressed ? pad.red : pad.green, k);
});
});
</script>
</body>
</html>