Key element

Key elements let you listen for presses on keyboard keys.


newKey("myKey", "FJ")

Since PennController 1.4, you can also pass special key names like "Enter", "Shift", "Control" or "Escape" (see list on Named elements also accept multiple key arguments, e.g. [js]newKey(“answer”, “FJ”, “Escape”)[/js].


[js try=”true” highlight=”4,5″]newText(“instructions”, “Please press the spacebar”)
newKey(“space”, ” “)
newText(“thanks”, “Thank you!”)

The code above adds a text asking for a press of the spacebar key. The text Thank you! get printed below it only after the spacebar was pressed.

Note: pass the void string "" for a press on any key.


[yadawiki-list category=”NonTest command,Key element”]


[yadawiki-list category=”Test command,Key element”]