JS: Removed comments, added keyboard press for numbers

This commit is contained in:
NetMan 2024-01-15 23:05:55 +01:00
parent a431af2f51
commit f74e37364d
1 changed files with 11 additions and 39 deletions

View File

@ -133,31 +133,8 @@ function generateGui() {
],
];
// const buttonsValues = [
// [7,8,9,"+"],
// [4,5,6,"-"],
// [1,2,3,"*"],
// [0,".","=","/"],
// ];
const buttonsDiv = document.querySelector("#buttons");
// for (let i = 0; i < 4; i++) {
// let button_row = document.createElement("div");
// button_row.classList.add("buttons-flex");
// for (let j = 0; j < 4; j++) {
// let button = document.createElement("div");
// button.classList.add("button");
// button.setAttribute("value", buttonsValues[i][j]);
// button.textContent = `${buttonsValues[i][j]}`;
// button.addEventListener("click", (event) => {
// click(event.target.getAttribute("value"));
// });
// button_row.append(button);
// }
// buttonsDiv.append(button_row);
// }
const table = document.createElement("table");
table.id = "table";
@ -177,21 +154,16 @@ function generateGui() {
table.append(tableRow);
});
buttonsDiv.append(table);
// let button_row = document.createElement("div");
// button_row.classList.add("buttons-flex");
// for (let j = 0; j < 4; j++) {
// let button = document.createElement("div");
// button.classList.add("button");
// button.setAttribute("value", buttonsValues[i][j]);
// // button.textContent = `${buttonsValues[i][j]}`;
// button.addEventListener("click", (event) => {
// click(event.target.getAttribute("value"));
// });
// button_row.append(button);
// }
// buttonsDiv.append(button_row);
// }
// }
}
generateGui();
document.addEventListener("keydown", numbers);
function numbers(e) {
e = e || window.event;
let passLetter = e.key.toLowerCase();
if (!isNaN(+passLetter)) {
click(passLetter);
}
}