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

@@ -71,8 +71,35 @@ const mute = () => {
const fullscreen = () => {
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>
<svelte:window on:keypress={keypress} />
<div class="container">
{#if
$nav.base.file_type === "video/x-matroska" ||