For accessibility requirements, Shift+ is F10supposed to open the context menu of the context menu.
In Swing, one approach is simply to add key bindings to every component you make. However, I experimented with the EventQueue extension to handle all presses Shift+ F10. In particular, I redefined dispatchEvent (AWTEvent) to convert Shift+ F10KeyEvents to the right mouse button:
protected void dispatchEvent(AWTEvent event) {
if (event instanceof KeyEvent) {
KeyEvent ev = (KeyEvent) event;
if ((ev.getKeyCode() == KeyEvent.VK_F10) &&
(ev.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) > 0) {
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
Component comp = kfm.getFocusOwner();
Point mouse = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(mouse, comp);
eventToDispatch = new MouseEvent(comp,
MouseEvent.MOUSE_RELEASED, ev.getWhen(), 0, mouse.x, mouse.y,
1, true);
}
}
}
However, this prevents the ability to Shift+ F10close any JPopupMenus that starts. Any idea if this solution is workable, or are there any better ways to fulfill this requirement?