boolean (int k, int modifiers) { Object focus = focusTargets.get(currentFocusTarget); if (focus == myEmojiSkinTonesPanel) { if (myEmojiSkinTonesPanel.isVisible()) { switch (k) { case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: myEmojiSkinTonesPanel.focusItem(k == KeyEvent.VK_DOWN ? 1 : -1); return true; case KeyEvent.VK_ENTER: case KeyEvent.VK_SPACE: case KeyEvent.VK_TAB: myEmojiSkinTonesPanel.setCurrentItemFromFocus(); case KeyEvent.VK_ESCAPE: selectSkinToneFromPanel(); return true; } } else if (k == KeyEvent.VK_ENTER || k == KeyEvent.VK_SPACE) { openSkinToneSelectionPanel(); myEmojiSkinTonesPanel.focusItem(1); return true; } } switch (k) { case KeyEvent.VK_TAB -> { int direction = (modifiers & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK ? -1 : 1; currentFocusTarget = (currentFocusTarget + direction + focusTargets.size()) % focusTargets.size(); myCategoryPanel.repaint(); mySearchField.repaint(); return true; } case KeyEvent.VK_ESCAPE -> { myInputCallback.accept(null); return true; } case KeyEvent.VK_UP, KeyEvent.VK_DOWN, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT -> { resetFocus(); if (!emojiNavigationMode) { emojiNavigationMode = k == KeyEvent.VK_UP || k == KeyEvent.VK_DOWN || (k == KeyEvent.VK_LEFT && mySearchField.getCaretPosition() == 0) || (k == KeyEvent.VK_RIGHT && mySearchField.getCaretPosition() == mySearchField.getText().length()); } if (!myEmojiListPanel.hasCurrentItem()) emojiNavigationMode = false; if (emojiNavigationMode) { myEmojiListPanel.navigate( keyToOffset(k, KeyEvent.VK_RIGHT, KeyEvent.VK_LEFT), keyToOffset(k, KeyEvent.VK_DOWN, KeyEvent.VK_UP) ); return true; } else { return false; } } } if (focus instanceof EmojiCategory) { if (k == KeyEvent.VK_ENTER || k == KeyEvent.VK_SPACE) { selectCategory((EmojiCategory)focus, true); return true; } } else if (focus == mySearchField && k == KeyEvent.VK_ENTER) { myEmojiListPanel.selectCurrentEmoji(); return true; } return false; }