implement inverse key
This commit is contained in:
parent
972513ea75
commit
328c4b9e22
5
main.js
5
main.js
|
|
@ -55,7 +55,7 @@ function keyPress(c) {
|
|||
const begin = currentInput.value.slice(0, selectionStart);
|
||||
const end = currentInput.value.slice(selectionEnd);
|
||||
currentInput.value = begin + c + end;
|
||||
currentInput.setSelectionRange(selectionStart+1, selectionStart+1);
|
||||
currentInput.setSelectionRange(selectionStart+c.length, selectionStart+c.length);
|
||||
}
|
||||
|
||||
function backspace() {
|
||||
|
|
@ -107,10 +107,11 @@ document.querySelector("#lparen").addEventListener("click", () => keyPress("("))
|
|||
document.querySelector("#rparen").addEventListener("click", () => keyPress(")"));
|
||||
|
||||
document.querySelector("#pow").addEventListener("click", () => keyPress("^"));
|
||||
document.querySelector("#inv").addEventListener("click", () => keyPress("^-1"));
|
||||
|
||||
document.querySelector("#clear").addEventListener("click", clear);
|
||||
document.querySelector("#enter").addEventListener("click", evaluate);
|
||||
|
||||
document.querySelector("#backspace").addEventListener("click", backspace);
|
||||
|
||||
// TODO implement square root and inverse keys
|
||||
// TODO implement square root key
|
||||
|
|
|
|||
Loading…
Reference in New Issue