deps/winpty/misc/GetCh.cc
raw| 1 | #include <conio.h> |
| 2 | #include <ctype.h> |
| 3 | #include <stdio.h> |
| 4 | |
| 5 | int main() { |
| 6 | printf("\nPress any keys -- Ctrl-D exits\n\n"); |
| 7 | |
| 8 | while (true) { |
| 9 | const int ch = getch(); |
| 10 | printf("0x%x", ch); |
| 11 | if (isgraph(ch)) { |
| 12 | printf(" '%c'", ch); |
| 13 | } |
| 14 | printf("\n"); |
| 15 | if (ch == 0x4) { // Ctrl-D |
| 16 | break; |
| 17 | } |
| 18 | } |
| 19 | return 0; |
| 20 | } |