key.settings.callback

getKey(id).settings.callback( command )

or getKey(id).settings.callback( command1, command2 )

Will execute the command(s) whenever a key corresponding to the element is pressed.

Example:

[js highlight=”7-17″ try=”true”]newText(“sentence”, “Hello world”)
.print()
,
newVar(“word”, 0)
,
newKey(“control”, ” \n\r”)
.settings.callback(
getText(“sentence”)
.settings.color(“red”)
,
newTimer(1000)
.start()
.wait()
,
getText(“sentence”)
.settings.color(“black”)
)[/js]

Prints Hello world onto the page and will highlight it in red for 1s whenever the Space or the Enter/Return key is pressed.