Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: KeyTrigger

[16:7] extends: FxObj

Wraps FXGL's KeyTrigger (com.almasb.fxgl.input.KeyTrigger), a data class pairing a KeyCode with an optional InputModifier (NONE / CTRL / SHIFT / ALT). KeyTrigger implements the Trigger interface and is the canonical "Ctrl+S" style binding object for Input.addAction and Input.rebind.

Methods

  • KeyTrigger (string KeyName = "SPACE", string ModifierName = "NONE")

    Creates a new KeyTrigger from a KeyCode name plus an optional modifier name.

    • @p KeyName is the KeyCode enum name (e.g. "S", "SPACE").
    • @p ModifierName is the InputModifier name ("NONE", "CTRL", "SHIFT", "ALT"). Defaults to "NONE".
  • adopt (object Ajo)

    Wraps an existing KeyTrigger AussomJavaObject.

    • @p Ajo is an AussomJavaObject around a KeyTrigger.
    • @r A new wrapper.
  • getName ()

    Returns the JavaFX KeyCode label for this trigger's key (e.g. "S", "Space"). Note: this does not include the modifier prefix — call toString() on the underlying AJO (e.g. kt.obj.invoke("toString")) to read the "CTRL+S" style combined label.

  • getKey ()

    Returns the KeyCode AussomJavaObject.

  • getModifier ()

    Returns the InputModifier AussomJavaObject.

  • isKey ()

    Returns true (KeyTrigger is always key-typed).

  • isButton ()

    Returns false (KeyTrigger is never button-typed).

  • isTriggered (object EventObj)

    Returns true when the given JavaFX InputEvent matches both the key and the modifier of this trigger.

    • @p EventObj is an AussomJavaObject around an InputEvent.
    • @r A bool.
  • isReleased (object EventObj)

    Returns true when the given JavaFX InputEvent matches a release of this trigger (either the key released or the modifier key released).

    • @p EventObj is an AussomJavaObject around an InputEvent.
    • @r A bool.