KeyStroke (KeyStroke stroke, InputMap map, int code, boolean onKeyRelease, String action) { if (stroke != null && code != stroke.getKeyCode()) { map.remove(stroke); stroke = null; } if (stroke == null && code != KeyEvent.VK_UNDEFINED) { stroke = KeyStroke.getKeyStroke(code, InputEvent.ALT_DOWN_MASK, onKeyRelease); map.put(stroke, action); } return stroke; }