diff --git a/script.js b/script.js index 7c69e39..6bc38d8 100644 --- a/script.js +++ b/script.js @@ -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(); \ No newline at end of file +generateGui(); + +document.addEventListener("keydown", numbers); + +function numbers(e) { + e = e || window.event; + let passLetter = e.key.toLowerCase(); + if (!isNaN(+passLetter)) { + click(passLetter); + } +} \ No newline at end of file