From 89a59109bea8c65b3fcb0a3a841e5ab57bfcdf95 Mon Sep 17 00:00:00 2001 From: Emil Krebs Date: Fri, 22 Dec 2023 22:20:29 +0100 Subject: [PATCH] added escape close --- hugo/content/playground/_index.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hugo/content/playground/_index.html b/hugo/content/playground/_index.html index 4be91f3a..f4a58aa3 100644 --- a/hugo/content/playground/_index.html +++ b/hugo/content/playground/_index.html @@ -35,7 +35,7 @@ const contentRoot = document.getElementById('content-root'); let isTreeInteractive = false; - + // register a listener for the share button shareButton.onclick = () => { @@ -83,6 +83,13 @@ forceGraphModal.classList.toggle('invisible'); }; + document.addEventListener('keydown', (event) => { + const graphShown = !forceGraphModal.classList.contains('invisible'); + if (event.key === 'Escape' && graphShown) { + forceGraphModal.classList.toggle('invisible'); + } + }); + const url = new URL(window.location.toString()); const grammar = url.searchParams.get('grammar'); const content = url.searchParams.get('content');