[josm-dev] Register for keys/shortcuts

Sebastian Klein bastikln at googlemail.com
Mon May 17 14:26:45 BST 2010


Matthias Meißer wrote:
> Sorry folks for my newbie questions but I doesn't get a working solution 
> to get callbacks if somebody presses the cursor keys in the main window.
> 
> main.parent.addkeyeventlistener(this); doesn't work, too :(
> 
> Is there some kind of Input map or does I have to use another approach 
> like creating an own JOSM mode?
> 
> Matthias

It's done countless times in JOSM source code. The direct approach would be
 
Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,0), 
actionname);

Aren't you computer science student? ;)


Sebastian




More information about the josm-dev mailing list