Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(nativeEvent: NativeElement) => {
const keyEvt = new QKeyEvent(nativeEvent);
const text = keyEvt.text();
const isNotNumber = isNaN(parseInt(text));
onBtnClick(text, isNotNumber ? "command" : "value");
}
);
const onKeyRelease = (evt: NativeEvent) => {
const operatorKeys = ["~", "/", "*", "-", "=", "+"];
const valueKeys = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "."];
const keyEvt = new QKeyEvent(evt);
const keyText = keyEvt.text();
if (operatorKeys.includes(keyText)) {
dispatch({ type: "operation", value: keyText });
} else if (valueKeys.includes(keyText)) {
dispatch({ type: "value", value: keyText });
}
};