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: | Sarah |
|---|---|
| Location: | Portland, Oregon |
| Users: | 170 |
| Nodes: | 16 (0 / 16) |
| Uptime: | 222:26:19 |
| Calls: | 1,204 |
| Calls today: | 1,204 |
| Files: | 85,018 |
| U/L today: |
554 files (10,683M bytes) |
| D/L today: |
3,990 files (9,159M bytes) |
| Messages: | 70,138 |
| Posted today: | 55 |