KeyStroke (String string) { if (string != null) { StringTokenizer st = new StringTokenizer(string, " "); int modifiers = 0; boolean typed = false; boolean pressed = false; boolean released = false; int count = st.countTokens(); for (int i = 1; i <= count; i++) { String token = st.nextToken(); if (typed) { if (st.hasMoreTokens()) { LOG.error("key stroke declaration has more tokens: " + st.nextToken()); return null; } if (token.length() != 1) { LOG.error("unexpected key stroke character: " + token); return null; } return getKeyStroke(token.charAt(0), modifiers); } String tokenLowerCase = StringUtil.toLowerCase(token); if (pressed || released || i == count) { if (st.hasMoreTokens()) { LOG.error("key stroke declaration has more tokens: " + st.nextToken()); return null; } Integer code = LazyVirtualKeys.myNameToCode.get(tokenLowerCase); if (code == null) { try { code = Integer.decode(token); } catch (NumberFormatException exception) { LOG.error("unexpected key stroke code: " + token); return null; } } return getKeyStroke(code, modifiers, released); } switch (tokenLowerCase) { case "typed" -> typed = true; case "pressed" -> pressed = true; case "released" -> released = true; default -> { Integer mask = LazyModifiers.mapNameToMask.get(tokenLowerCase); if (mask == null) { LOG.error("unexpected key stroke modifier: " + token); return null; } modifiers |= mask; } } } LOG.error("key stroke declaration is not completed"); } return null; }