Implement Vim key bindings.

This commit is contained in:
Jannik Schäfer 2022-12-13 21:59:11 +01:00
parent c4607bd6c6
commit eb79e190a6
No known key found for this signature in database
1 changed files with 23 additions and 0 deletions

View File

@ -830,8 +830,31 @@ var UI = (() => {
break; break;
case "Home": case "Home":
newRow = row; 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": case "ArrowUp":
dir = "previous"; dir = "previous";
case "KeyJ":
case "ArrowDown": case "ArrowDown":
if (!newRow) { if (!newRow) {
this.customize(null); this.customize(null);