From 7a50f7910e7996dedfa3231450f060dbcb247bdf Mon Sep 17 00:00:00 2001 From: Bulat Musin Date: Mon, 5 Feb 2018 15:08:46 +0300 Subject: [PATCH] add support for F9 - toggle sidebar --- src/theme/book.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/theme/book.js b/src/theme/book.js index fe3d17cb..f797e679 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -455,6 +455,26 @@ function playpen_text(playpen) { } }, { passive: true }); + document.addEventListener('keydown', function (e) { + if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; } + + switch (e.key) { + case 'F9': + if (html.classList.contains("sidebar-hidden")) { + showSidebar(); + } else if (html.classList.contains("sidebar-visible")) { + hideSidebar(); + } else { + if (getComputedStyle(sidebar)['transform'] === 'none') { + hideSidebar(); + } else { + showSidebar(); + } + } + break; + } + }); + // Scroll sidebar to current active section var activeSection = sidebar.querySelector(".active"); if (activeSection) {