Skip to content

Commit 93e1433

Browse files
authored
docs: keyboard only search navigation (#1932)
1 parent 5dc2fa8 commit 93e1433

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/api/ApiIndex.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ function apiSearchFocusHandler(event: KeyboardEvent): void {
5353
} else {
5454
apiFilter.value!.blur();
5555
}
56+
} else if (event.key === 'Enter') {
57+
if (apiFilter.value !== document.activeElement) return;
58+
if (query.value === '') return;
59+
const item = filtered.value[0].items[0];
60+
if (!item) return;
61+
const header = item.headers[0];
62+
if (!header) return;
63+
window.location.href = item.link + '.html#' + slugify(header.anchor);
5664
} else if (
5765
/^[a-z]$/.test(event.key) &&
5866
!event.altKey &&

0 commit comments

Comments
 (0)