add shortcut keys

This commit is contained in:
ajuvercr 2020-03-21 16:29:30 +01:00
parent def6f62726
commit 422989bebc

View file

@ -152,6 +152,7 @@
}
const createColourButtons = () => {
const colourSecectors = [];
COLOURS.forEach((colour, i) => {
$colourButtonWrapper = document.querySelector(".colourButtonWrapper");
$button = document.createElement("input");
@ -160,6 +161,9 @@
$button.classList.add("colourButton");
$button.type = "radio";
$button.value = i;
colourSecectors.push($button);
$checkmark = document.createElement("span");
$checkmark.classList.add("colourButtonCheckmark");
$checkmark.classList.add("colourButton_"+colour);
@ -169,6 +173,14 @@
$container.append($checkmark);
$colourButtonWrapper.append($container);
})
document.addEventListener("keyup", (e) => {
var key = event.key || event.keyCode;
try {
colourSecectors[parseInt(key) - 1].checked = true;
} catch (_) {
}
});
}
const handleChangeAmountOfSquares = e => {