libConsole/Getch.java
changeset 55 2a20d0184041
parent 49 77094ec383cf
equal deleted inserted replaced
54:c064ce9f40f5 55:2a20d0184041
     3 public class Getch {
     3 public class Getch {
     4     public static void main (String args[]) {
     4     public static void main (String args[]) {
     5         int c;
     5         int c;
     6 
     6 
     7         System.out.println ("Press q or ESCAPE to quit");
     7         System.out.println ("Press q or ESCAPE to quit");
       
     8 
     8         for (;;) {
     9         for (;;) {
     9             c = Console.getch ();
    10             c = Console.getch ();
    10             switch (c) {
    11             switch (c) {
    11             case 27:
    12             case 27:
    12             case 'q':
    13             case 'q':
    13                 System.exit (0);
    14                 System.exit (0);
    14                 break;
    15                 break;
    15             default:
    16             default:
    16                 System.out.printf ("KEY: %c (%d)\n", c, c);
    17                 System.out.printf ("KEY: %c (%d)\n", c, c);
       
    18                 break;
    17             }
    19             }
    18         }
    20         }
    19     };
    21     };
    20 };
    22 }