add support for F9 - toggle sidebar

This commit is contained in:
Bulat Musin 2018-02-05 15:08:46 +03:00
parent 1dae72f23f
commit 7a50f7910e
1 changed files with 20 additions and 0 deletions

View File

@ -455,6 +455,26 @@ function playpen_text(playpen) {
} }
}, { passive: true }); }, { 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 // Scroll sidebar to current active section
var activeSection = sidebar.querySelector(".active"); var activeSection = sidebar.querySelector(".active");
if (activeSection) { if (activeSection) {