Key Mapping

defineKey(JComponent jComponent , String keystroke , PnutsFunction func { , int condition } ) or
(JComponent jComponent , String keystroke , Action action { , int condition } )

defineKey() registers a keystroke to invoke the func or the action. This function is assumed to be used with Swing.

keystroke is passed to KeyStroke::getKeyStroke(String) method, and a KeyStroke object is created.

condition is one of:

e.g.
defineKey(JTextPane(), "control alt K", function (e) println(e))
defineKey(JTextPane(), "released X", function (e) println(e))
getKeyStroke(String keystroke )

getKeyStroke() makes a swing KeyStroke object. It is a shortcut to KeyStroke::getKeyStroke(String) method.


Back