00001
00002
00009
00010 package pkgView;
00011
00012 import java.util.*;
00013
00015 public class Keyboard {
00016
00017
00018 private ScreenKit sk;
00019 private int lastKey = 0;
00020
00021 private static Keyboard instance = null;
00022
00026 private Keyboard(){
00027 sk = ScreenKit.getSingleton();
00028 };
00029
00030
00035 public static Keyboard getSingleton() {
00036 if ( instance == null) {
00037 instance = new Keyboard();
00038 }
00039 return instance;
00040 }
00041
00042
00043
00044 public int inputKey(int timeout){
00045 lastKey = sk.ttyGetKey(timeout);
00046 return lastKey;
00047 }
00048
00049
00052 public void setKey( int setting ){
00053 lastKey = setting;
00054 }
00055
00056
00060 public int getLastKey(){
00061 return lastKey;
00062 }
00063
00064
00065 public static final int KEY_F12 = 276;
00066 public static final int KEY_F11 = 275;
00067 public static final int KEY_F10 = 274;
00068 public static final int KEY_F9 = 273;
00069 public static final int KEY_F8 = 272;
00070 public static final int KEY_F7 = 271;
00071 public static final int KEY_F6 = 270;
00072 public static final int KEY_F5 = 269;
00073 public static final int KEY_F4 = 268;
00074 public static final int KEY_F3 = 267;
00075 public static final int KEY_F2 = 266;
00076 public static final int KEY_F1 = 265;
00077 public static final int KEY_TAB = 9;
00078 public static final int KEY_ESC = 27;
00079 public static final int KEY_ENTER = 13;
00080 public static final int KEY_NEWMODE = 0;
00081
00082 public static final int KEY_HOME = 262;
00083 public static final int KEY_DOWN = 258;
00084 public static final int KEY_UP = 259;
00085 public static final int KEY_RIGHT = 261;
00086 public static final int KEY_LEFT = 260;
00087
00088 public static final int KEY_PGDN = 338;
00089 public static final int KEY_PGUP = 339;
00090
00091 public static final int KEY_INSERT = 331;
00092 public static final int KEY_DELETE = 330;
00093
00094 public static final int KEY_SPACE = 32;
00095
00096 public static final int
00097 KEY_CTRL_A = 1,
00098 KEY_CTRL_B = 2,
00099 KEY_CTRL_C = 3,
00100 KEY_CTRL_D = 4,
00101 KEY_CTRL_E = 5,
00102 KEY_CTRL_F = 6,
00103 KEY_CTRL_G = 7,
00104 KEY_CTRL_H = 8,
00105 KEY_CTRL_I = 9,
00106 KEY_CTRL_J = 10,
00107 KEY_CTRL_K = 11,
00108 KEY_CTRL_L = 12,
00109 KEY_CTRL_M = 13,
00110 KEY_CTRL_N = 14,
00111 KEY_CTRL_O = 15,
00112 KEY_CTRL_P = 16,
00113 KEY_CTRL_Q = 17,
00114 KEY_CTRL_R = 18,
00115 KEY_CTRL_S = 19,
00116 KEY_CTRL_T = 20,
00117 KEY_CTRL_U = 21,
00118 KEY_CTRL_V = 22,
00119 KEY_CTRL_W = 23,
00120 KEY_CTRL_X = 24,
00121 KEY_CTRL_Y = 25,
00122 KEY_CTRL_Z = 26
00123 ;
00124
00125
00129 public boolean isBackSpace( int k ){
00130 if( k == 127 ){
00131 return true;
00132 }
00133 return false;
00134 }
00135
00136
00140 public boolean isLeftArrow( int k ){
00141 if( k == 260 ){
00142 return true;
00143 }
00144 return false;
00145 }
00146
00147
00151 public boolean isRightArrow( int k ){
00152 if( k == 261 ){
00153 return true;
00154 }
00155 return false;
00156 }
00157
00158
00162 public boolean isCtrl( int k ){
00163 if( k >= 1 && k <= 26 ){
00164 return true;
00165 }
00166 return false;
00167 }
00168
00169
00173 public boolean isDigit( int k ){
00174 if( k >= '0' && k <= '9' ){
00175 return true;
00176 }
00177 return false;
00178 }
00179
00180
00184 public boolean isLower( int k ){
00185 if( k >= 'a' && k <= 'z' ){
00186 return true;
00187 }
00188 return false;
00189 }
00190
00191
00195 public boolean isUpper( int k ){
00196 if( k >= 'A' && k <= 'Z' ){
00197 return true;
00198 }
00199 return false;
00200 }
00201
00202 public boolean isAlpha( int k ){
00203 if( isUpper(k) || isLower(k) ){
00204 return true;
00205 }
00206 return false;
00207 }
00208
00209
00210 }
00211