Class ModifierKeys

java.lang.Object
com.luciad.input.ModifierKeys

public final class ModifierKeys extends Object
Utility class that contains the combination of the modifier keys pressed.

The modifiers keys are mapped to the following values:

  • None => 0
  • Alt => 1
  • Ctrl => 2
  • Shift => 4

Note
Don't use the hasFlag method if you want to check that there are no modifiers set, instead do
    ModifierKeys shift = ModifierKeys.Shift;
    boolean checkNone = shift.equals(ModifierKeys.None);
    assertFalse(checkNone);
    ModifierKeys none = ModifierKeys.None;
    checkNone = none.equals(ModifierKeys.None);
    assertTrue(checkNone);

An example usage is:

    ModifierKeys ctrl = ModifierKeys.Ctrl;
    ModifierKeys alt = ModifierKeys.Alt;
    ModifierKeys ctrlAlt = ctrl.or(alt);

    boolean isNone = ctrlAlt.equals(ModifierKeys.None);
    boolean isAlt = ctrlAlt.hasFlag(ModifierKeys.Alt);
    boolean isCtrlAlt = ctrlAlt.equals(ModifierKeys.Alt.or(ModifierKeys.Ctrl));
See Also:
  • KeyCode for the available key codes to use in conjunction with this class.
  • Field Details

  • Constructor Details

    • ModifierKeys

      public ModifierKeys(long keys)
      Creates a new instance.
      Parameters:
      keys - the bits that represent the modifier keys.
  • Method Details

    • and

      @NotNull public ModifierKeys and(@NotNull ModifierKeys other)
    • or

      @NotNull public ModifierKeys or(@NotNull ModifierKeys other)
    • hasFlag

      public boolean hasFlag(@NotNull ModifierKeys keys)
      Returns if the specified modifier keys are pressed.
      Parameters:
      keys -
      Returns:
      if the keys are pressed
    • getKeys

      public long getKeys()
      Returns the combined pressed modifier keys.
      Returns:
      the combined pressed modifier keys.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object