Implement Vim key bindings.
This commit is contained in:
parent
c4607bd6c6
commit
eb79e190a6
23
src/ui/ui.js
23
src/ui/ui.js
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue