Add video skip keys

This commit is contained in:
2024-08-14 18:21:13 +02:00
parent de819bfedb
commit 3d128a2960
3 changed files with 59 additions and 0 deletions

View File

@@ -224,6 +224,11 @@ onMount(() => {
<tr><td>d or &#8594;</td><td> = View next item in list</td></tr> <tr><td>d or &#8594;</td><td> = View next item in list</td></tr>
<tr><td>r</td><td> = Toggle shuffle (<b><u>r</u></b>andom)</td></tr> <tr><td>r</td><td> = Toggle shuffle (<b><u>r</u></b>andom)</td></tr>
<tr><td>SHIFT + s</td><td> = Download all the files in the list as a zip archive</td></tr> <tr><td>SHIFT + s</td><td> = Download all the files in the list as a zip archive</td></tr>
<tr><td colspan="2">Video Shortcuts</td></tr>
<tr><td>h</td><td> = Skip 20 seconds backward</td></tr>
<tr><td>j</td><td> = Skip 5 seconds backward</td></tr>
<tr><td>k</td><td> = Skip 5 seconds forward</td></tr>
<tr><td>l</td><td> = Skip 20 seconds forward</td></tr>
</table> </table>
</div> </div>

View File

@@ -83,8 +83,35 @@ const mute = () => {
const fullscreen = () => { const fullscreen = () => {
player.requestFullscreen() player.requestFullscreen()
} }
const keypress = e => {
if (
(e.ctrlKey || e.altKey || e.metaKey) ||
(document.activeElement.type && (
document.activeElement.type === "text" ||
document.activeElement.type === "email" ||
document.activeElement.type === "textarea"))
) {
// The first check is to prevent our keybindings from triggering then
// the user uses a global keybind. The second check is to prevent the
// shortcuts from firing if the user is entering text in an input field
return
}
if (e.key === "h") {
seek_relative(-20)
} else if (e.key === "j") {
seek_relative(-5)
} else if (e.key === "k") {
seek_relative(5)
} else if (e.key === "l") {
seek_relative(20)
}
}
</script> </script>
<svelte:window on:keypress={keypress} />
{#if file.allow_video_player} {#if file.allow_video_player}
{#if !video_reload} {#if !video_reload}
<div class="container"> <div class="container">

View File

@@ -71,8 +71,35 @@ const mute = () => {
const fullscreen = () => { const fullscreen = () => {
player.requestFullscreen() player.requestFullscreen()
} }
const keypress = e => {
if (
(e.ctrlKey || e.altKey || e.metaKey) ||
(document.activeElement.type && (
document.activeElement.type === "text" ||
document.activeElement.type === "email" ||
document.activeElement.type === "textarea"))
) {
// The first check is to prevent our keybindings from triggering then
// the user uses a global keybind. The second check is to prevent the
// shortcuts from firing if the user is entering text in an input field
return
}
if (e.key === "h") {
seek_relative(-20)
} else if (e.key === "j") {
seek_relative(-5)
} else if (e.key === "k") {
seek_relative(5)
} else if (e.key === "l") {
seek_relative(20)
}
}
</script> </script>
<svelte:window on:keypress={keypress} />
<div class="container"> <div class="container">
{#if {#if
$nav.base.file_type === "video/x-matroska" || $nav.base.file_type === "video/x-matroska" ||