From 103a5026f95c52df891a922eb1b0a0ca6921b73f Mon Sep 17 00:00:00 2001 From: David Ernst Date: Sat, 4 May 2019 21:04:41 -0700 Subject: [PATCH 1/2] Add YouTube style hotkeys. Closes #1395 --- src/renderer/main.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/renderer/main.js b/src/renderer/main.js index 887fb4dbd0..00042f14b0 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -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) @@ -507,6 +510,32 @@ 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) + } + + update() +} + function onFocus (e) { state.window.isFocused = true state.dock.badge = 0 From 07816f74705e03477cbe54928ac0769f53d333dd Mon Sep 17 00:00:00 2001 From: David Ernst Date: Mon, 6 May 2019 09:58:47 -0700 Subject: [PATCH 2/2] Add f=fullscreen hotkey --- src/renderer/main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/renderer/main.js b/src/renderer/main.js index 00042f14b0..b5415d5770 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -531,6 +531,8 @@ function onKeydown (e) { dispatch('changePlaybackRate', 1) } else if (key === '<') { dispatch('changePlaybackRate', -1) + } else if (key === 'f') { + dispatch('toggleFullScreen') } update()