add shortcut keys
This commit is contained in:
parent
def6f62726
commit
422989bebc
1 changed files with 12 additions and 0 deletions
|
@ -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 => {
|
||||
|
|
Loading…
Reference in a new issue