Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: KeyInputBuilder

[25:7] extends: FxObj

Wraps FXGL's KeyInputBuilder (com.almasb.fxgl.dsl.KeyInputBuilder), the fluent setup for binding a key (optionally with a modifier and virtual button) to an Aussom callback set. Construct via one of the fxgl.onKeyBuilder(...) factory overloads — the underlying UserAction is registered with the active Input service in the builder's constructor. Wiring: wKey = aji.getStaticMember("javafx.scene.input.KeyCode", "W"); fxgl.onKeyBuilder(wKey) .onActionBegin(::startMoving) .onAction(::keepMoving) .onActionEnd(::stopMoving);

Methods

  • KeyInputBuilder (Ajo = null)

    Wraps an existing KeyInputBuilder AussomJavaObject (the usual entry, since fxgl.onKeyBuilder(...) returns a wrapper with the AJO already populated). The factory methods register the underlying UserAction with the supplied Input service in the Kotlin constructor, so there is no Aussom-side no-arg ctor that would build a standalone instance.

    • @p Ajo is an optional AussomJavaObject around a KeyInputBuilder.
  • adopt (object Ajo)

    Wraps an existing KeyInputBuilder AussomJavaObject.

  • onActionBegin (callback Cb)

    Sets the once-on-press handler.

    • @p Cb is a callback () -> void.
  • onAction (callback Cb)

    Sets the held-down handler (fires every tick the key is down).

    • @p Cb is a callback () -> void.
  • onActionEnd (callback Cb)

    Sets the once-on-release handler.

    • @p Cb is a callback () -> void.