Class KeyBinding.Builder

java.lang.Object
jfx.incubator.scene.control.input.KeyBinding.Builder
Enclosing class:
KeyBinding

public static class KeyBinding.Builder extends Object
A builder for KeyBinding objects.

By default, its build method creates a key KEY_PRESSED binding. This can be changed by calling either keyReleased() or keyTyped().

The builder pattern can be used when convenience methods such as KeyBinding.control(KeyCode) or KeyBinding.shiftShortcut(KeyCode) are not sufficient.

Example: KeyBinding.builder(KeyCode.TAB).control().option().shift().build()

Since:
24
  • Method Details

    • keyReleased

      public KeyBinding.Builder keyReleased()
      Sets the KEY_RELEASED condition, clearing KEY_PRESSED and KEY_TYPED.
      Returns:
      the Builder instance
    • keyTyped

      public KeyBinding.Builder keyTyped()
      Sets the KEY_TYPED condition, clearing KEY_PRESSED and KEY_RELEASED.
      Returns:
      the Builder instance
    • alt

      public KeyBinding.Builder alt()
      Sets the alt key down condition (the option key on macOS).
      Returns:
      this Builder
    • command

      public KeyBinding.Builder command()
      Sets the command key down condition on macOS.

      Setting this condition on non-macOS platforms will result in the build method returning null.

      Returns:
      this Builder
    • control

      public KeyBinding.Builder control()
      Sets the control key down condition.
      Returns:
      this Builder
    • meta

      public KeyBinding.Builder meta()
      Sets the meta key down condition.
      Returns:
      this Builder
    • option

      public KeyBinding.Builder option()
      Sets the option key down condition on macOS.

      Setting this condition on non-macOS platforms will result in the build method returning null.

      Returns:
      this Builder
    • shift

      public KeyBinding.Builder shift()
      Sets the shift key down condition.
      Returns:
      this Builder
    • shortcut

      public KeyBinding.Builder shortcut()
      Sets the shortcut key down condition.
      Returns:
      this Builder
    • build

      public KeyBinding build()
      Creates a new KeyBinding instance from the current settings.
      Returns:
      a new key binding instance.