mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 11:01:45 +00:00
add optional arrowkeys controls option
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
const { setOptions } = require("../../config/plugins");
|
||||
const { ipcRenderer } = require("electron");
|
||||
|
||||
module.exports = (options) => {
|
||||
setPlaybarOnwheel(options);
|
||||
setObserver(options);
|
||||
firstRun(options);
|
||||
setupArrowShortcuts(options);
|
||||
};
|
||||
|
||||
function saveVolume(volume, options) {
|
||||
@ -42,6 +44,28 @@ function setPlaybarOnwheel(options) {
|
||||
};
|
||||
}
|
||||
|
||||
function setupArrowShortcuts(options) {
|
||||
//change options from renderer to keep sync
|
||||
ipcRenderer.on("setArrowsShortcut", (event, value) => {
|
||||
options.arrowsShortcut = value;
|
||||
setOptions("precise-volume", options);
|
||||
});
|
||||
|
||||
//register shortcuts if enabled
|
||||
if (options.arrowsShortcut) {
|
||||
window.addEventListener('keydown', (event) => {
|
||||
switch (event.code) {
|
||||
case `ArrowUp`:
|
||||
changeVolume(true, options);
|
||||
break;
|
||||
case `ArrowDown`:
|
||||
changeVolume(false, options);
|
||||
break;
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
function changeVolume(increase, options) {
|
||||
// Need to change both the slider and the actual volume
|
||||
const videoStream = document.querySelector(".video-stream");
|
||||
|
||||
Reference in New Issue
Block a user