Merge pull request 'A few improvements ;)' (#1) from ctucx/webmusic:master into master

Reviewed-on: https://git.zotan.services/zotan/webmusic/pulls/1
This commit is contained in:
Laura Hausmann 2021-03-05 23:05:46 +01:00
commit 86abe310d3
No known key found for this signature in database
GPG key ID: 338D7F50C0B814EE

View file

@ -20,9 +20,13 @@ window.onload = function () {
updateState()
};
document.addEventListener("keypress", function onEvent(event) {
if (event.key === "p") {
togglePlayback();
window.onkeyup = function (event) {
if (event.key === " " || event.key === "p") {
if (gstate !== "idle") {
togglePlayback();
} else {
playSong(queue[0])
}
}
else if (event.key === "r") {
toggleRepeat();
@ -30,7 +34,23 @@ document.addEventListener("keypress", function onEvent(event) {
else if (event.key === "c") {
toggleContinue();
}
});
else if (event.key === "ArrowUp") {
previousTrack();
}
else if (event.key === "ArrowDown") {
nextTrack();
}
else if (event.key === "ArrowLeft") {
if (sound.seek() < 10) {
sound.seek(0);
} else {
sound.seek(sound.seek()-10);
}
}
else if (event.key === "ArrowRight") {
sound.seek(sound.seek()+10);
}
};
function togglePlayback() {