Class HotkeyButton

All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants

public class HotkeyButton extends JButton
A button component for capturing keyboard hotkey bindings.

HotkeyButton allows users to set keyboard shortcuts by clicking the button and pressing the desired key combination. The button displays the current keybind and updates when a new key is pressed.

Usage:

  1. Click the button (left mouse button) to clear the current binding
  2. Press any key or key combination to set the new binding
  3. The button text updates to show the current binding

The button supports both regular keybinds (with modifiers like Ctrl, Alt, Shift) and modifierless keybinds (single key without modifiers).

Example usage:


 HotkeyButton hotkeyButton = new HotkeyButton(Keybind.NOT_SET, false);
 // Listen for changes
 hotkeyButton.addPropertyChangeListener("value", e -> {
     Keybind newBinding = (Keybind) e.getNewValue();
     saveHotkey(newBinding);
 });
 

See Also:
  • Constructor Details

    • HotkeyButton

      public HotkeyButton(net.runelite.client.config.Keybind value, boolean modifierless)
      Creates a new HotkeyButton with the specified initial value.
      Parameters:
      value - the initial keybind, or null for no binding
      modifierless - if true, captures keys without modifiers; if false, captures full key combinations
  • Method Details

    • setValue

      public void setValue(net.runelite.client.config.Keybind value)
      Sets the keybind value and updates the button text.
      Parameters:
      value - the new keybind value, or null to clear (sets to NOT_SET)