diff --git a/src/ui/ui.js b/src/ui/ui.js index 1830f20..91057ef 100644 --- a/src/ui/ui.js +++ b/src/ui/ui.js @@ -830,8 +830,31 @@ var UI = (() => { break; case "Home": newRow = row; + case "KeyH": + dir = "previous"; + case "KeyL": + const presets = row.querySelectorAll("input[class='preset']"); + const currentIndex = [...presets].findIndex((p) => p.checked); + const step = dir === "next" ? 1 : -1; + const len = presets.length; + + for (let i = 1; i < len; i++) { + // Limit nextIndex to [0, len). + const nextIndex = (currentIndex + len + i * step) % len; + + // Skip disabled presets. + if (!presets[nextIndex].disabled) { + const nextPreset = presets[nextIndex]; + nextPreset.focus(); + nextPreset.click(); + break; + } + } + break; + case "KeyK": case "ArrowUp": dir = "previous"; + case "KeyJ": case "ArrowDown": if (!newRow) { this.customize(null);