aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2022-01-04 12:16:31 +0000
committers-ol <s+removethis@s-ol.nu>2022-01-04 12:16:31 +0000
commit2341addccd53f81248a615f44b58d5588eae3eba (patch)
treeba04e99e9fc26802f0662ef3c63cbb3598907cc8
parentadd chord display (diff)
downloadisomorphic-kb-explorer-2341addccd53f81248a615f44b58d5588eae3eba.tar.gz
isomorphic-kb-explorer-2341addccd53f81248a615f44b58d5588eae3eba.zip
fix keyboard mapping
-rw-r--r--app/app.js6
-rw-r--r--app/notes.js48
2 files changed, 30 insertions, 24 deletions
diff --git a/app/app.js b/app/app.js
index 172a908..00b18bb 100644
--- a/app/app.js
+++ b/app/app.js
@@ -192,17 +192,23 @@ export default class App extends React.Component {
}
onkeydown = (e) => {
+ if (e.repeat) return;
+
const note = notes.key2midi[e.code];
if (!note) return;
e.preventDefault();
this.setState(({ notes }) => ({ notes: { ...notes, [note]: true } }));
+ this.send(NOTE_ON, note);
}
onkeyup = (e) => {
+ if (e.repeat) return;
+
const note = notes.key2midi[e.code];
if (!note) return;
e.preventDefault();
this.setState(({ notes }) => ({ notes: { ...notes, [note]: false } }));
+ this.send(NOTE_OFF, note);
}
render() {
diff --git a/app/notes.js b/app/notes.js
index 0e3e92d..3d71a41 100644
--- a/app/notes.js
+++ b/app/notes.js
@@ -38,29 +38,29 @@ export const key2midi = {
'Quote': 74,
'Backslash': 76,
- 'KeyQ': 61,
- 'KeyW': 63,
- 'KeyE': 65,
- 'KeyR': 67,
- 'KeyT': 69,
- 'KeyY': 71,
- 'KeyU': 73,
- 'KeyI': 75,
- 'KeyO': 77,
- 'KeyP': 79,
- 'BracketLeft': 81,
- 'BracketRight': 83,
+ 'KeyQ': 59,
+ 'KeyW': 61,
+ 'KeyE': 63,
+ 'KeyR': 65,
+ 'KeyT': 67,
+ 'KeyY': 69,
+ 'KeyU': 71,
+ 'KeyI': 73,
+ 'KeyO': 75,
+ 'KeyP': 77,
+ 'BracketLeft': 79,
+ 'BracketRight': 81,
- 'Digit1': 66,
- 'Digit2': 68,
- 'Digit3': 70,
- 'Digit4': 72,
- 'Digit5': 74,
- 'Digit6': 76,
- 'Digit7': 78,
- 'Digit8': 80,
- 'Digit9': 82,
- 'Digit0': 84,
- 'Minus': 86,
- 'Equal': 88,
+ 'Digit1': 64,
+ 'Digit2': 66,
+ 'Digit3': 68,
+ 'Digit4': 70,
+ 'Digit5': 72,
+ 'Digit6': 74,
+ 'Digit7': 76,
+ 'Digit8': 78,
+ 'Digit9': 80,
+ 'Digit0': 82,
+ 'Minus': 84,
+ 'Equal': 86,
};