Skip to content

Commit

Permalink
Merge pull request #33 from paganotoni/feature-ctrl-k-support
Browse files Browse the repository at this point in the history
task: allowing to trigger the search with ctrl+k
  • Loading branch information
paganotoni authored Jun 15, 2024
2 parents bc8ceb5 + 2fc5e09 commit 6150559
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions internal/assets/doco.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ let doco = {
document.getElementById("search-input").addEventListener("keyup", (e) => {
doco.search.do(e.target.value)
});

// Up and down navigation.
document.addEventListener("keydown", () => {
let paletteVisible = document
Expand All @@ -85,10 +86,7 @@ let doco = {
}

let selector = "#search-results li.selected";
let quickLinksVisisble = document
.querySelector("#search-quick-actions")
.classList.contains("hidden");

let quickLinksVisisble = document.querySelector("#search-quick-actions").classList.contains("hidden");
if (!quickLinksVisisble) {
selector = "#search-quick-actions li.selected";
}
Expand Down Expand Up @@ -136,17 +134,16 @@ let doco = {

//Esc and CMD+k toggle
document.addEventListener("keydown", (e) => {
if (e.keyCode === 27) {
// Close search on ESC
if (e.code === 'Escape') {
doco.search.hide();
// hide image container
imageContainer.classList.add("hidden");
}

if (e.keyCode >= 65 && e.keyCode <= 90) {
let char = (e.metaKey ? "⌘-" : "") + String.fromCharCode(e.keyCode);
if (char == "⌘-K") {
// CMD+k or CTRL+k
if ((e.key === 'K' || e.key === 'k') && (e.metaKey || e.ctrlKey)) {
doco.search.show();
}
}
});

Expand Down

0 comments on commit 6150559

Please sign in to comment.