JavaScript Calculator keyboard input behaves differently with mouse click

Hi,
I’m currently working on the JavaScript Calculator and have noticed a discrepancy in how keyboard input behaves compared to mouse clicks.

For example,

Input Mouse result Keyboard result Corresponding function
0000 0 0 handleNum
1234 1234 1234 handleNum
. . . . . 0.0.0.0. handleNum
1.1.1 1.11 10.10.1 handleNum
//// / //// handleOps , doubleOpsCheck
1 * 7 = 7 0 handleNum , handleOps
1 * 7 = 2 2 0 handleNum , handleOps

When inputting numbers, the keyboard behaves the same as mouse clicks (e.g. inputting 0000 or 1234). Surprisingly, multiple leading zeros are handled properly for keyboard input. However, for decimal input “.”, which is also handled by the handleNum function, keyboards fail to work properly.

When inputting operators, the “=” key never successfully calculates the result. Consecutive inputs of operators are also not handled properly with keyboard input.

Overall, the results from mouse clicks are satisfactory, but the keyboard results are confusing, as it works in some cases but is broken in others. I’m unsure why this is happening and would appreciate it if someone could provide more insight into this keyboard problem.

Below is the codepen
https://codepen.io/pikapipipi/pen/VwRxPBP

Thank you.