Skip to content

Commit 2dbbe44

Browse files
committed
fixed issue css harsh98trivedi#10
1 parent e011611 commit 2dbbe44

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

index.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,41 @@ <h1><a style="text-decoration: none; color: #f1c40f; margin-left: 1.25rem;" href
149149
toggleMode.addEventListener('change', function() {
150150
container.classList.toggle('dark-mode');
151151
});
152+
document.addEventListener('keydown', function (event) {
153+
handleKeyPress(event.key);
154+
});
155+
// 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+
function handleKeyPress(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+
function handleButtonPress(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
182+
const button = document.querySelector(`button[value="${value}"]`);
183+
if (button) {
184+
button.click();
185+
}
186+
}
187+
152188
</script>
153189
</html>

style.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,7 @@ input:checked + .toggle-slider:before {
275275
display: flex;
276276
font-size: 1rem;
277277
}
278-
278+
279+
#answer {
280+
caret-color: #0f38f1;
281+
}

0 commit comments

Comments
 (0)