String (KeyStroke stroke) { if (stroke != null) { StringBuilder sb = new StringBuilder(); int modifiers = stroke.getModifiers(); append(sb, "shift", modifiers, InputEvent.SHIFT_DOWN_MASK); append(sb, "ctrl", modifiers, InputEvent.CTRL_DOWN_MASK); append(sb, "meta", modifiers, InputEvent.META_DOWN_MASK); append(sb, "alt", modifiers, InputEvent.ALT_DOWN_MASK); append(sb, "altGraph", modifiers, InputEvent.ALT_GRAPH_DOWN_MASK); append(sb, "button1", modifiers, InputEvent.BUTTON1_DOWN_MASK); append(sb, "button2", modifiers, InputEvent.BUTTON2_DOWN_MASK); append(sb, "button3", modifiers, InputEvent.BUTTON3_DOWN_MASK); int code = stroke.getKeyCode(); if (code != KeyEvent.VK_UNDEFINED) { append(sb, "released", stroke.isOnKeyRelease()); String name = LazyVirtualKeys.myCodeToName.get(code); if (name == null) { sb.append('#'); name = Integer.toHexString(code); } return sb.append(name).toString(); } char ch = stroke.getKeyChar(); if (ch != KeyEvent.CHAR_UNDEFINED) { append(sb, "typed", true); return sb.append(ch).toString(); } LOG.error("undefined key stroke"); } return null; }