From 4ae66e2e43f43ac0ccbffd2778b6123c687a7fd6 Mon Sep 17 00:00:00 2001 From: Syl Date: Sat, 13 Jan 2024 17:09:39 -0600 Subject: [PATCH] enter key now cycles through conversion options --- html/afterload/conversionOptions.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/html/afterload/conversionOptions.js b/html/afterload/conversionOptions.js index 96cd57e..995d0c4 100644 --- a/html/afterload/conversionOptions.js +++ b/html/afterload/conversionOptions.js @@ -113,6 +113,8 @@ const setupConvertDownload = (node, info, colorScheme) => { const ffmpegCustomOptions = ffmpegOptions.querySelector(`#ffmpegCustomOptions`); + const downloadButton = ffmpegOptions.parentElement.lastElementChild.querySelector(`#confirmDownload`) + let buttons = ffmpegOptions.querySelectorAll(`.formatPreset`); let currentSelected = null; @@ -502,6 +504,22 @@ const setupConvertDownload = (node, info, colorScheme) => { setPreset(usableOption ? ffmpegOptions.querySelector(`#${usableOption}`) || null : null, true); // set default preset resetTrim(false) + + const textboxes = ffmpegOptions.querySelectorAll(`input[type="text"]`); + + textboxes.forEach((box, i) => { + box.onkeyup = (e) => { + const shift = (e.key == `Shift` || e.keyCode == 16); + const tab = (e.key == `Tab` || e.keyCode == 9); + const enter = (e.key == `Enter` || e.keyCode == 13); + + if((shift && enter) || (enter && i == textboxes.length - 1)) { + downloadButton.click(); + } else if(enter && i < textboxes.length - 1) { + textboxes[i+1].focus(); + }; + } + }); node.querySelector(`#conversionDiv`).appendChild(node.querySelector(`#outputExtension`) || listboxTemplate.querySelector(`#outputExtension`).cloneNode(true)); }