Skip to content

Commit

Permalink
subtitles offset keybinding
Browse files Browse the repository at this point in the history
  • Loading branch information
carlo-colombo committed Feb 9, 2024
1 parent 675a59a commit 54eb554
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/subtitlesync/subtitlesync.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ function init(instance) {
}
};

document.addEventListener('keydown', function(event) {
if (event.key == 'g' || event.key == 'h') {
SubtitleSync.prototype.toggle();
const mod = event.key == 'g' ? -0.1 : +0.1;
const value = new Intl.NumberFormat({ maximumFractionDigits: 1 })
.format(parseFloat(subtitleSyncSlider.value) + mod);
subtitleSyncSlider.updateOffset(value);
}
event.stopPropagation();
event.preventDefault();
});

function updateSubtitleOffset() {
const value = parseFloat(subtitleSyncSlider.value);
// set new offset
Expand Down

0 comments on commit 54eb554

Please sign in to comment.