There is a method with an additional boolean argument for this
KeyStroke.getKeyStroke(int keyCode, int modifiers, boolean onKeyRelease)
The method you discovered works on key press, so this:
KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0);
is equivalent to
KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0, false);
If you want to get this working on the release of F10, use
KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0, true);