I register
getInputMap().put(KeyStroke.getKeyStroke("pressed RIGHT"), "go right");
When testing the code I get: While I hold the right arrow key down, the action is triggered repeatedly and not only once as I would have expected this.
Interestingly
getInputMap().put(KeyStroke.getKeyStroke("released RIGHT"), "stop");
triggers stop only when the key is finally released.
Is there a way to register a key stroke on an input map, so that the associated action is only triggered once at the moment when the key is pressed?
KeyListener
doesn't help when your scenario isWHEN_IN_FOCUSED_WINDOW
... – Gripe