|
61 | 61 | <head> |
62 | 62 | <title>KRISCALCULATOR</title> |
63 | 63 | <link rel="stylesheet" type="text/css" href="kris.css"> |
64 | | -<style> |
65 | | -input::-webkit-outer-spin-button, |
66 | | -input::-webkit-inner-spin-button |
67 | | -{ |
68 | | --webkit-appearance: none; |
69 | | -margin: 0; |
70 | | -} |
71 | | -input[type=number] { |
72 | | --moz-appearance: textfield; |
73 | | -} |
74 | | -</style> |
| 64 | + |
75 | 65 | </head> |
76 | 66 | <body> |
77 | 67 | <form> |
@@ -136,25 +126,52 @@ function action1(a) { |
136 | 126 | xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
137 | 127 | xmlhttp.send("cal="+cstr); |
138 | 128 | } |
139 | | - function myFunction (evt) { |
| 129 | +function myFunction (evt) { |
140 | 130 | var kCode = (evt.which) ? evt.which : evt.keyCode |
141 | | -if (kCode == 107) {action1("+"); |
| 131 | +//limiting key press applicable to numeric keys and arithematic functions |
| 132 | +if (kCode>95&&kCode<106) { |
| 133 | + } else if (kCode==8) { |
| 134 | +} else if (kCode==110) { |
| 135 | +} |
| 136 | +else if (kCode == 39) {action1("^"); |
| 137 | +evt.preventDefault(); |
| 138 | +return false;} |
| 139 | +else if (kCode == 220) {action1("√"); |
| 140 | +evt.preventDefault(); |
| 141 | +return false;} |
| 142 | +else if (kCode == 107) {action1("+"); |
142 | 143 | evt.preventDefault(); |
143 | 144 | return false;} |
144 | 145 | else if (kCode == 109) {action1("-"); |
145 | 146 | evt.preventDefault(); |
146 | 147 | return false;} |
147 | | -else if (kCode == 106) {action1("*");return false;} |
148 | | -else if (kCode == 111) {action1("/");return false;} |
149 | | -else if (kCode == 46) {action1("D");return false;} |
| 148 | +else if (kCode == 187) {action1("="); |
| 149 | +evt.preventDefault(); |
| 150 | +return false;} |
| 151 | +else if (kCode == 106) {action1("*"); |
| 152 | +evt.preventDefault(); |
| 153 | +return false;} |
| 154 | +else if (kCode == 111) {action1("/"); |
| 155 | +evt.preventDefault(); |
| 156 | +return false;} |
| 157 | +else if (kCode == 46) {action1("D"); |
| 158 | +evt.preventDefault(); |
| 159 | +return false;} |
150 | 160 | else if (kCode == 13) {action1("="); |
151 | 161 | evt.preventDefault(); |
152 | 162 | return false;} |
153 | | -else if (kCode == 61) {action1("=");return false;} |
154 | | - } |
| 163 | +else if (kCode == 61) {action1("="); |
| 164 | +evt.preventDefault(); |
| 165 | +return false;} |
| 166 | + else { |
| 167 | + |
| 168 | + evt.preventDefault(); |
| 169 | + return false; |
| 170 | +} |
| 171 | +} |
155 | 172 | </script> |
156 | 173 | <?php |
157 | | -echo "<table class='tablem'><tr><td colspan=4 class='full'><input type='number' onkeydown='myFunction(event)' id='inpt' value='' class='numbfl' autocomplete='off' autofocus /></td>"; |
| 174 | +echo "<table class='tablem'><tr><td colspan=4 class='full'><input type='text' onkeydown='myFunction(event)' id='inpt' value='' class='numbfl' autocomplete='off' autofocus /></td>"; |
158 | 175 | echo "<tr><td colspan=4 class='full' id='display1'></td>"; |
159 | 176 | echo "<tr><td colspan=4 class='full' id='display2'></td>"; |
160 | 177 | echo "<tr><td class='onefr' onclick=action1('D');>DEL</td><td class='onefr' onclick=action1('√');>√</td><td class='onefr' onclick=action1('^');>^</td><td class='onefr' onclick=action1('=');>=</td>"; |
|
0 commit comments