@theoryofnekomata/piano-keyboard
v1.0.2
Published
Simple piano keyboard in JavaScript
Downloads
8
Maintainers
Readme
piano-keyboard
A piano keyboard in JavaScript.
Why?
- Because most JavaScript keyboards aren't simple and customizable enough.
- I'm creating a piano roll control, so it needs a piano keyboard to work.
- This is ideal for music software that utilizes keyboards.
Installation
NPM:
$ npm install --save @theoryofnekomata/piano-keyboard
Bower:
$ bower install --save piano-keyboard
Usage
In your HTML:
<!-- ... -->
<div id="piano-element" data-white-key-width="auto"></div>
<!-- ... -->
In your JavaScript:
// ...
var pianoElement = document.getElementById('piano-element');
new PianoKeyboard(pianoElement);
pianoElement.addEventListener('noteon', function onNoteOn(e) {
// ...
});
pianoElement.addEventListener('noteoff', function onNoteOff(e) {
// ...
});
// ...
License
MIT. See LICENSE file for details.