spanish-quizzer

An app to quiz you on Spanish vocabulary and verb conjugations
git clone https://git.ashermorgan.net/spanish-quizzer/
Log | Files | Refs | README

commit b659d8da7ebd9bbdcfd86e87e9fe71ab239d633c
parent aa149247242d754c4958c75fe0bf89138565e382
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date:   Thu, 13 Aug 2020 16:08:14 -0700

Implement more keyboard shortcuts.

Diffstat:
MScripts/Home.js | 38+++++++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/Scripts/Home.js b/Scripts/Home.js @@ -25,11 +25,7 @@ function Load() { document.addEventListener("click", function (e) { document.getElementById('share').hidden = true; }); - document.addEventListener("keydown", function (e) { - if (e.key === "Escape") { - TitleClicked(); - } - }); + document.addEventListener("keydown", KeyDown); document.getElementById("quizzerInput").addEventListener("keydown", function (e) { if (e.ctrlKey && e.keyCode === 13) { // Key was Ctrl+Enter @@ -123,3 +119,35 @@ function TitleClicked() { Show("home"); } } + + + +// Handles keyDown events (implements keyboard shortcuts) +function KeyDown(e) { + if (e.key === "Escape") { + TitleClicked(); + } + + // Home shortcuts + if (document.getElementById("home").hidden == false) { + if (e.key === "c") { + Show("verbs"); + } + if (e.key === "v") { + Show("vocab"); + } + if (e.key === "r") { + window.location = "/reference.html"; + } + } + + // Settings shortcuts + if (document.getElementById("settings").hidden == false) { + if (e.key === "s") { + CreateSession(); + } + if (e.key === "r") { + ResumeSession(); + } + } +}