Having an odd problem with a script I'm writing.
Consider the following JS code:
while (!script_exit) {
switch (console.inkey().toUpperCase()) {
case "A":
doThingOne();
break;
case "B":
doThingTwo();
break;
case KEY_ESC:
case "Q":
case "\r":
script_exit = true;
break;
default:
log("switch default"); // hits this every time
}
}
I'm trying to get a single key from the user and let the switch/case block handle accordingly. However, instead of waiting for input, it immediately falls to the default conition (as commented above).
If I change inkey to getkey, it works as expected. I'd prefer to use inkey instead of getkey though, to avoid showing the cursor while waiting for input.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,007 |
Nodes: | 10 (0 / 10) |
Uptime: | 174:36:07 |
Calls: | 13,143 |
Calls today: | 1 |
Files: | 186,574 |
D/L today: |
194 files (66,690K bytes) |
Messages: | 3,309,637 |