예제 #1
0
 // keyboard discovery code
 private void _mapKey(char charCode, int keyindex, boolean shift, boolean altgraph) {
   log("_mapKey: " + charCode);
   // if character is not in map, add it
   if (!charMap.containsKey(new Integer(charCode))) {
     log("Notified: " + (char) charCode);
     KeyEvent event =
         new KeyEvent(
             applet(),
             0,
             0,
             (shift ? KeyEvent.SHIFT_MASK : 0) + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0),
             ((Integer) vkKeys.get(keyindex)).intValue(),
             (char) charCode);
     charMap.put(new Integer(charCode), event);
     log("Mapped char " + (char) charCode + " to KeyEvent " + event);
     if (((char) charCode) >= 'a' && ((char) charCode) <= 'z') {
       // put shifted version of a-z in automatically
       int uppercharCode = (int) Character.toUpperCase((char) charCode);
       event =
           new KeyEvent(
               applet(),
               0,
               0,
               KeyEvent.SHIFT_MASK + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0),
               ((Integer) vkKeys.get(keyindex)).intValue(),
               (char) uppercharCode);
       charMap.put(new Integer(uppercharCode), event);
       log("Mapped char " + (char) uppercharCode + " to KeyEvent " + event);
     }
   }
 }