-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed
Description
I created the function below to meet accessibility requirements. When I first open the app and enter "1+1" and then press "=" I get "21" instead of "2". The calculator behave as expected after refreshing the page. Still it makes for a bad user experience.
function handleKeyPress(event) {
const key = event.key;
const button = document.querySelector(`[data-value="${key}"]`);
console.log(key)
if (button) {
button.click(); // Trigger the click event for the corresponding button
}
if (event.code === "Backspace") {
let newArray = data.slice(ZERO, -1);
screen.innerText = newArray.join("");
data = newArray;
if (screen.innerText === "") {
screen.innerText = ZERO;
}
}
if(event.code === "Enter") {
userClicksOnEqualButton("=");
}
}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed