class KeyBinding { int KEYCODE; public static final int SPECIALKEY_SHIFT_CONTROL_ALT = 7; public static final int SPECIALKEY_CONTROL_ALT = 6; public static final int SPECIALKEY_SHIFT_ALT = 5; public static final int SPECIALKEY_ALT = 4; public static final int SPECIALKEY_SHIFT_CONTROL = 3; public static final int SPECIALKEY_CONTROL = 2; public static final int SPECIALKEY_SHIFT = 1; public static final int SPECIALKEY_NONE = 0; private int SPECIALKEY = SPECIALKEY_NONE; String STRING = ""; KeyBinding(char k) { KEYCODE = int((str(k).toUpperCase()).charAt(0)); println(toCommand()+" "+STRING); } KeyBinding(char k, String s) { KEYCODE = int((str(k).toUpperCase()).charAt(0)); STRING = s; println(toCommand()+" "+STRING); } KeyBinding(int specialKey, char k, String s) { KEYCODE = int((str(k).toUpperCase()).charAt(0)); STRING = s; SPECIALKEY = specialKey; println(toCommand()+" "+STRING); } KeyBinding(boolean sh, boolean ct, boolean al) { KEYCODE = 0; SPECIALKEY = (al?1:0)<<2|(ct?1:0)<<1|(sh?1:0); } public boolean isPressed(int specialKeys, int kc) { boolean out = (specialKeys==SPECIALKEY&&kc==KEYCODE); if (out) println(STRING); return out; } public String toString() { return str(char(KEYCODE)); } public int getSpecialKey() { return SPECIALKEY; } public String specialKeyToString() { switch (SPECIALKEY) { case SPECIALKEY_NONE : return ""; case SPECIALKEY_SHIFT : return "[SHIFT]"; case SPECIALKEY_CONTROL : return "[CTRL]"; case SPECIALKEY_SHIFT_CONTROL : return "[SHIFT]-[CTRL]"; case SPECIALKEY_ALT : return "[ALT]"; case SPECIALKEY_SHIFT_ALT : return "[SHIFT]-[ALT]"; case SPECIALKEY_CONTROL_ALT : return "[CTRL]-[ALT]"; case SPECIALKEY_SHIFT_CONTROL_ALT : return "[SHIFT]-[CTRL]-[ALT]"; default: return ""; } } public String toCommand() { return specialKeyToString()+(SPECIALKEY!=SPECIALKEY_NONE?"-":"")+"["+toString()+"]"; } public char getKey() { return char(KEYCODE); } public String getString() { return STRING; } }