KeyStroke (String strokeText) { String s = strokeText.trim(); assert s.length() > 0; final String lowerCaseS = StringUtil.toLowerCase(s); boolean hasModifiers = lowerCaseS.contains("shift") || lowerCaseS.contains("control") || lowerCaseS.contains("alt") || lowerCaseS.contains("meta"); String symbol = null; int beforeSymbol = -1; boolean haveSymbol; KeyStroke symbolStroke = null; if (hasModifiers) { s = lowerCaseS;// Avoid adding extra SHIFT modifier for uppercase letters in shortcuts beforeSymbol = s.lastIndexOf(" "); haveSymbol = beforeSymbol > 0; } else { symbol = s; haveSymbol = true; } int modifiers = 0; if (haveSymbol) { if (symbol == null) { symbol = s.substring(beforeSymbol + 1); } if (symbol.length() > 1) { final Integer code = ReflectionUtil.getStaticFieldValue(KeyEvent.class, int.class, "VK_" + StringUtil.toUpperCase(symbol)); if (code == null) { return throwUnrecognized(symbol); } symbolStroke = KeyStroke.getKeyStroke(code.intValue(), 0); } String modifierPlusA = s.substring(0, s.length() - (s.length() - beforeSymbol - 1)) + "A"; final KeyStroke modifierPlusAStroke = KeyStroke.getKeyStroke(modifierPlusA); if (symbolStroke == null) { symbol = String.valueOf(symbol.charAt(0)); symbolStroke = get(symbol.charAt(0)); } modifiers = modifierPlusAStroke.getModifiers(); if ((symbolStroke.getModifiers() & KeyEvent.SHIFT_MASK) > 0) { modifiers |= KeyEvent.SHIFT_MASK; } } if (symbolStroke == null || symbolStroke.getKeyCode() == KeyEvent.VK_UNDEFINED) { return throwUnrecognized(symbol); } return KeyStroke.getKeyStroke(symbolStroke.getKeyCode(), modifiers, false); }