summaryrefslogtreecommitdiff
path: root/assets/js/shortcuts.js
blob: 6ed3c67430eb61b9f53ec74ff1fcf9927de052f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
document.onkeydown = (e) => {
    if ((e.metaKey || e.ctrlKey) && e.code === "Comma") {
        if (window.parent.currentSong === null) return;
        e.preventDefault();
        window.parent.stop();
        return false;
    }

    if ((e.metaKey || e.ctrlKey) && e.code === "ArrowRight") {
        if (window.parent.currentSong === null) return;
        e.preventDefault();
        window.parent.next();
        return false;
    }

    if ((e.metaKey || e.ctrlKey) && e.code === "ArrowLeft") {
        if (window.parent.currentSong === null) return;
        e.preventDefault();
        window.parent.previous();
        return false;
    }

    if (e.code === "Space" && e.target.tagName !== "INPUT") {
        if (window.parent.currentSong === null) return;
        e.preventDefault();
        window.parent.playPause();
        return false;
    }
}