diff options
-rw-r--r-- | app.js | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -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 | ||
57 | function onGetDeviceError(error) { | 70 | function onGetDeviceError(error) { |