mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
32 lines
919 B
JavaScript
32 lines
919 B
JavaScript
const { globalShortcut } = require("electron");
|
|
const electronLocalshortcut = require("electron-localshortcut");
|
|
|
|
const {
|
|
playPause,
|
|
nextTrack,
|
|
previousTrack,
|
|
startSearch
|
|
} = require("./youtube.js");
|
|
|
|
function _registerGlobalShortcut(webContents, shortcut, action) {
|
|
globalShortcut.register(shortcut, () => {
|
|
action(webContents);
|
|
});
|
|
}
|
|
|
|
function _registerLocalShortcut(win, shortcut, action) {
|
|
electronLocalshortcut.register(win, shortcut, () => {
|
|
action(win.webContents);
|
|
});
|
|
}
|
|
|
|
function registerShortcuts(win) {
|
|
_registerGlobalShortcut(win.webContents, "MediaPlayPause", playPause);
|
|
_registerGlobalShortcut(win.webContents, "MediaNextTrack", nextTrack);
|
|
_registerGlobalShortcut(win.webContents, "MediaPreviousTrack", previousTrack);
|
|
_registerLocalShortcut(win, "CommandOrControl+F", startSearch);
|
|
_registerLocalShortcut(win, "CommandOrControl+L", startSearch);
|
|
}
|
|
|
|
module.exports = registerShortcuts;
|