You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This function will be responsible for handling the button press from the keyboard..Try thses key also if want you can also chnage these settings,...
156
+
functionhandleKeyPress(key){
157
+
// "Enter" key is pressed, trigger the "=" button press
158
+
if(key==='Enter'){
159
+
handleButtonPress('=');
160
+
}
161
+
162
+
// "Delete" or "Backspace" key is pressed, trigger the "CE" button press
163
+
if(key==='Delete'||key==='Backspace'){
164
+
handleButtonPress('CE');
165
+
}
166
+
167
+
//number key is pressed, trigger the corresponding number button press
168
+
if(/[0-9]/.test(key)){
169
+
handleButtonPress(key);
170
+
}
171
+
172
+
// operator key is pressed (+, -, *, /), trigger the corresponding operator button press
173
+
if(/[\+\-\*\/%]/.test(key)){
174
+
handleButtonPress(key);
175
+
}
176
+
}
177
+
178
+
functionhandleButtonPress(value){
179
+
// This function simulates the button press of the calculator for the given value
180
+
181
+
// Find the corresponding button element based on the value
0 commit comments