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