anvilsign in

collin/browser-terminal-extension · 2f84c606

Move the omnibar selection with Alt+N and Alt+P too

Collin Richards · 2026-08-19 06:47 UTC · 2f84c606c35f41223366ad3ab1305163cd502bc9 · parent f93b743f · browse files

modifiedextension/sidebar.js+8 −2
⋯ 4885 unchanged lines
48864886 // Ctrl+J / Ctrl+K move the selection too, but only while the list is up:
48874887 // with nothing open they belong to the terminal, and Ctrl+K in particular is
48884888 // a line-kill an emacs-keyed shell expects to get.
4889- if (ev.ctrlKey && !ev.altKey && !ev.metaKey && (key === "j" || key === "k") && omniItems.length) {
4889+ const ctrlJK = ev.ctrlKey && !ev.altKey && !ev.metaKey && (key === "j" || key === "k");
4890+ // Alt+N / Alt+P are the same movement under readline's other hand, the pair a
4891+ // shell's history-search binds. They go by ev.code rather than ev.key because
4892+ // Alt is the compose modifier on some layouts (Alt+N is "ñ" on a Mac), so the
4893+ // key that arrives is not reliably an "n".
4894+ const altNP = ev.altKey && !ev.ctrlKey && !ev.metaKey && (ev.code === "KeyN" || ev.code === "KeyP");
4895+ if ((ctrlJK || altNP) && omniItems.length) {
48904896 e.preventDefault();
4891- moveOmni(key === "j" ? 1 : -1);
4897+ moveOmni(ctrlJK ? (key === "j" ? 1 : -1) : ev.code === "KeyN" ? 1 : -1);
48924898 } else if (key === "ArrowDown" || key === "ArrowUp") {
48934899 e.preventDefault();
48944900 moveOmni(key === "ArrowDown" ? 1 : -1);
⋯ 1225 unchanged lines