Class KeyBinder

  • All Implemented Interfaces:

    
    public final class KeyBinder
    
                        

    KeyBinder handles key bindings for the PolyUI instance.

    • Constructor Detail

      • KeyBinder

        KeyBinder(Settings settings)
    • Method Detail

      • getHasTimeSensitiveListeners

         final Boolean getHasTimeSensitiveListeners()

        Property which enables an optimization where the KeyBinder will only update after every frame if there are time-sensitive listeners.

        Since:

        1.1.1

      • accept

        @ApiStatus.Internal() final Boolean accept(Event event, Byte mods)

        accept a keystroke event. This will call all keybindings that match the event.

        This method is public, but marked as internal. This is because it should only be called by the PolyUI instance, unless you are trying to externally force a keypress (which you probably shouldn't be)

      • accept

        @ApiStatus.Internal() final Boolean accept(Integer key, Boolean down, Byte mods)

        accept an unmapped keystroke event. This will call all keybindings that match the event.

        This method is public, but marked as internal. This is because it should only be called by the PolyUI instance, unless you are trying to externally force a keypress (which you probably shouldn't be)

      • add

         final Unit add(KeyBinder.Bind binds)

        Add a keybind to this PolyUI instance, that will be run when the given keys are pressed.

        Since:

        1.1.7

      • add

         final Unit add(KeyBinder.Bind bind)

        Add a keybind to this PolyUI instance, that will be run when the given keys are pressed.

        Since:

        0.21.0

      • record

         final Unit record(Long holdDurationNanos, Function1<KeyBinder.Bind, Unit> callback, Function1<Boolean, Boolean> function)

        Begin recording for a keybind. The resulting keybind, which will be passed to the callback, is not registered automatically.

        recording may be cancelled for the following reasons:

        • the ESC key is pressed

        • record is called again before the recording is completed, (i.e. starting a new one before the old one is finished)

        • the instance already has a keybind which matched the one being recorded

        • the keybind was attempted to be set to just left-click (which is not allowed)

        Parameters:
        holdDurationNanos - the duration that the keys have to be pressed in the resultant keybind
        callback - the function that will be called when recording is completed.
        function - the function that will be run when the keybind is pressed.
        Since:

        0.24.0

      • release

        @ApiStatus.Internal() final Unit release()

        Synthetically drop all pressed keys