Skip to content

Commit

Permalink
Merge branch 'master' into replace-old-hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
dsernst committed May 6, 2019
2 parents 90723ed + 8b0b5f3 commit e9b1462
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ function onState (err, _state) {
// ...same thing if you paste a torrent
document.addEventListener('paste', onPaste)

// Add YouTube style hotkey shortcuts
window.addEventListener('keydown', onKeydown)

const debouncedFullscreenToggle = debounce(function () {
dispatch('toggleFullScreen')
}, 1000, true)
Expand Down Expand Up @@ -507,6 +510,34 @@ function onPaste (e) {
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)
} else if (key === 'f') {
dispatch('toggleFullScreen')
}

update()
}

function onFocus (e) {
state.window.isFocused = true
state.dock.badge = 0
Expand Down

0 comments on commit e9b1462

Please sign in to comment.