-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyboard.js
43 lines (43 loc) · 1.03 KB
/
keyboard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
document.addEventListener("keydown", function(event){
//event.preventDefault();
switch(event.key){
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
case "0":
case ".":
push(event.key);
break;
case ",":
push(".");
break;
case "+":
case "-":
case "/":
case "*":
addOperation(event.key);
break;
case "Backspace":
pop();
break;
case "Escape":
reset();
break;
case "Enter":
calc();
break;
}
if(event.ctrlKey){
if(event.key == "a" || event.key == "A"){
event.preventDefault();
//window.getSelection().removeAllRanges();
window.getSelection().selectAllChildren(document.getElementById("current"));
}
}
});