Add YouTube style hotkeys. Closes #1395
This commit is contained in:
@@ -147,6 +147,9 @@ function onState (err, _state) {
|
|||||||
// ...same thing if you paste a torrent
|
// ...same thing if you paste a torrent
|
||||||
document.addEventListener('paste', onPaste)
|
document.addEventListener('paste', onPaste)
|
||||||
|
|
||||||
|
// Add YouTube style hotkey shortcuts
|
||||||
|
window.addEventListener('keydown', onKeydown)
|
||||||
|
|
||||||
const debouncedFullscreenToggle = debounce(function () {
|
const debouncedFullscreenToggle = debounce(function () {
|
||||||
dispatch('toggleFullScreen')
|
dispatch('toggleFullScreen')
|
||||||
}, 1000, true)
|
}, 1000, true)
|
||||||
@@ -507,6 +510,32 @@ function onPaste (e) {
|
|||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onKeydown (e) {
|
||||||
|
const key = e.key
|
||||||
|
|
||||||
|
if (key === 'ArrowLeft') {
|
||||||
|
dispatch('skip', -5)
|
||||||
|
} else if (key === 'ArrowRight') {
|
||||||
|
dispatch('skip', 5)
|
||||||
|
} else if (key === 'ArrowUp') {
|
||||||
|
dispatch('changeVolume', 0.1)
|
||||||
|
} else if (key === 'ArrowDown') {
|
||||||
|
dispatch('changeVolume', -0.1)
|
||||||
|
} else if (key === 'j') {
|
||||||
|
dispatch('skip', -10)
|
||||||
|
} else if (key === 'l') {
|
||||||
|
dispatch('skip', 10)
|
||||||
|
} else if (key === 'k') {
|
||||||
|
dispatch('playPause')
|
||||||
|
} else if (key === '>') {
|
||||||
|
dispatch('changePlaybackRate', 1)
|
||||||
|
} else if (key === '<') {
|
||||||
|
dispatch('changePlaybackRate', -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
update()
|
||||||
|
}
|
||||||
|
|
||||||
function onFocus (e) {
|
function onFocus (e) {
|
||||||
state.window.isFocused = true
|
state.window.isFocused = true
|
||||||
state.dock.badge = 0
|
state.dock.badge = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user