public static int jkeycode2X11code(int jcode, int location) {
    if (jcode >= KeyEvent.VK_A && jcode <= KeyEvent.VK_Z)
      return XK_a + (jcode - KeyEvent.VK_A);

    if (jcode >= KeyEvent.VK_0 && jcode <= KeyEvent.VK_9)
      return XK_0 + (jcode - KeyEvent.VK_0);
    if (jcode >= KeyEvent.VK_NUMPAD0 && jcode <= KeyEvent.VK_NUMPAD9)
      return XK_KP_0 + (jcode - KeyEvent.VK_NUMPAD0);

    if (jcode >= KeyEvent.VK_F1 && jcode <= KeyEvent.VK_F12)
      return XK_F1 + (jcode - KeyEvent.VK_F1);

    if (jcode >= KeyEvent.VK_F13 && jcode <= KeyEvent.VK_F24)
      return XK_F13 + (jcode - KeyEvent.VK_F1);

    if (jcode == KeyEvent.VK_SHIFT) {
      if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0)
        return XK_Shift_R;
      return XK_Shift_L;
    }
    if (jcode == KeyEvent.VK_CONTROL) {
      if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0)
        return XK_Control_R;
      return XK_Control_L;
    }
    if (jcode == KeyEvent.VK_ALT) {
      if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0)
        return XK_Alt_R;
      return XK_Alt_L;
    }
    if (jcode == KeyEvent.VK_META) {
      if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0)
        return XK_Meta_R;
      return XK_Meta_L;
    }
    if (jcode == KeyEvent.VK_WINDOWS) {
      if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0)
        return XK_Super_R;
      return XK_Super_L;
    }

    return _jkeycode2x11keycode(jcode);
  }
public static int jkeycode2X11code(int jcode, int location)