This repository was archived by the owner on Aug 8, 2020. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork1
Piano keyboard React component.
License
NotificationsYou must be signed in to change notification settings
TheoryOfNekomata/react-musical-keyboard.old
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Musical keyboard component for React.
react-musical-keyboard
is inspired by the UI/UX of keyboards on FL Studio's piano roll.
npm install --save react-musical-keyboard
importReactfrom'react'importMusicalKeyboardfrom'react-musical-keyboard'constKEYBOARD_MAPPING={// key code to note ID mapping81:60,50:61,87:62,51:63,69:64,82:65,53:66,84:67,// ...}constApp=()=>{handleKeyOn=({value:{ id, velocity}})=>{// ...maybe use the Web Audio/MIDI API to generate sounds?}handleKeyOff=({value:{ id}})=>{// ...}return(<MusicalKeyboardstyle={{height:'8vw',width:'100%',position:'fixed',bottom:0,left:0,}}labels={key=>withLabels ?`${PITCH_NAMES[key.id%12]}${Math.floor(key.id/12)-1}` :null}onKeyOn={handleKeyOn}onKeyOff={handleKeyOff}startKey={0/* C0 in MIDI, Middle C (C5) is 60 */}endKey={127/* G10 in MIDI */}accidentalKeyHeight={'65%'/* percentage value, relative to white key height */}keyboardMapping={KEYBOARD_MAPPING}naturalKeyColor={'white'/* any CSS color, applies to all white keys */}accidentalKeyColor={'black'/* any CSS color, applies to all black keys */}/>)
MIT ©Temoto-kun
About
Piano keyboard React component.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.