diff --git a/static/js/shortcut.js b/static/js/shortcut.js index abece38..e1bf225 100644 --- a/static/js/shortcut.js +++ b/static/js/shortcut.js @@ -29,6 +29,14 @@ function checkCount() { return false; } +function check(choice) { + value = checkedGroups[0]; + removeId(); + getid = choice+value; + document.getElementById(getid).checked = true; + checkCount(); +} + window.addEventListener("keydown", function (event) { if (event.defaultPrevented) { return; @@ -40,18 +48,10 @@ window.addEventListener("keydown", function (event) { switch (event.key) { case "a": - value = checkedGroups[0]; - removeId(); - getid = 'a'+value; - document.getElementById(getid).checked = true; - checkCount(); + check("a"); break; case "b": - value = checkedGroups[0]; - removeId(); - getid = 'b'+value; - document.getElementById(getid).checked = true; - checkCount(); + check("b"); break; default: checkCount();