User inputs are handled by the InputHandler, which is part of SceneryBase and Hubable. Adding inputs can be done in an overwrite of the inputSetup method of SceneryBase. First a Behavior needs to be added before a key can be assigned.
Adding a Behavior
A behavior defines an action which is executed when the corresponding keys are pressed. There are currently the following base behaviors from which can be inherited: ClickBehavior, DragBehavior, ScrollBehavior.
In most cases a ClickBehavior is used. Example:
val helloClick =object : ClickBehaviour {val output ="Hello World"overridefunclick(x: Int, y: Int) { logger.info(output +"at $x and $y") }}
In cases where the x and y screen positions of the cursor are not needed, they are just ignored. Adding a behavior to the InputHandler is straightforward: