For some unknown reason, this code doesn't work.
JTextComponent component = new JTextArea();
Keymap keymap = component.getKeymap();
keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.ALT_DOWN_MASK), myAction);
It never triggers myAction when I press Alt and 1 (not on the numpad, the 1 above the letters). This also does not work for any modifier.
The solution given here https://stackoverflow.com/a/11974908/3838784 does not work, the action is still not triggered. Removing all keystrokes from the key map that have ALT as a modifier does not seem to help either.
I tried a sample, using your code, it seems to be working fine. Can you let me know if anything is different from your code?