Frage

I have a java program, and I want to keybind just the meta key, not another key with a meta mask. Is there any way to do this? Here's my attempt that failed:

getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_META, 0), "meta-down");
getActionMap().put("meta-down", new MetaDownAction(this));
War es hilfreich?

Lösung

So I found out that the way to do this is to detect a meta key mask too, as depicted below.

getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_META, InputEvent.META_DOWN_MASK), "meta-down");
getActionMap().put("meta-down", new MetaDownAction(this));
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top