aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/app.js b/app.js
index 762a72f..19d0867 100644
--- a/app.js
+++ b/app.js
@@ -44,7 +44,6 @@ function onGetDeviceSuccess(stream) {
44 clips.prepend(wrapElement("li", audioElement)); 44 clips.prepend(wrapElement("li", audioElement));
45 }); 45 });
46 46
47 // TODO: handle "space" key hold the same as holding the "record" button
48 recordBtn.addEventListener("mousedown", _event => { 47 recordBtn.addEventListener("mousedown", _event => {
49 mediaRecorder.start(); 48 mediaRecorder.start();
50 }); 49 });
@@ -52,6 +51,20 @@ function onGetDeviceSuccess(stream) {
52 recordBtn.addEventListener("mouseup", _event => { 51 recordBtn.addEventListener("mouseup", _event => {
53 mediaRecorder.stop(); 52 mediaRecorder.stop();
54 }); 53 });
54
55 document.addEventListener("keydown", event => {
56 if (mediaRecorder.state == "inactive" && event.key == " ") {
57 event.preventDefault(); // prevent scroll
58 mediaRecorder.start();
59 }
60 });
61
62 document.addEventListener("keyup", event => {
63 if (event.key == " ") {
64 event.preventDefault(); // prevent scroll
65 mediaRecorder.stop();
66 }
67 });
55} 68}
56 69
57function onGetDeviceError(error) { 70function onGetDeviceError(error) {