public final class ModifierKeys extends Object
The modifiers keys are mapped to the following values:
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));
KeyCode
Modifier and Type | Field and Description |
---|---|
static ModifierKeys |
Alt
A
ModifierKeys instance that represents the Alt modifier key. |
static ModifierKeys |
Ctrl
A
ModifierKeys instance that represents the Ctrl modifier key. |
static ModifierKeys |
None
A
ModifierKeys instance that represents no modifier keys. |
static ModifierKeys |
Shift
A
ModifierKeys instance that represents the Shift modifier key. |
Constructor and Description |
---|
ModifierKeys(long keys)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
ModifierKeys |
and(ModifierKeys other) |
boolean |
equals(Object other) |
long |
getKeys() |
boolean |
hasFlag(ModifierKeys keys)
Returns if the specified modifier keys are pressed.
|
int |
hashCode() |
ModifierKeys |
or(ModifierKeys other) |
public static final ModifierKeys None
ModifierKeys
instance that represents no modifier keys.public static final ModifierKeys Alt
ModifierKeys
instance that represents the Alt modifier key.public static final ModifierKeys Ctrl
ModifierKeys
instance that represents the Ctrl modifier key.public static final ModifierKeys Shift
ModifierKeys
instance that represents the Shift modifier key.public ModifierKeys(long keys)
keys
- the bits that represent the modifier keys.@NotNull public ModifierKeys and(@NotNull ModifierKeys other)
@NotNull public ModifierKeys or(@NotNull ModifierKeys other)
public boolean hasFlag(@NotNull ModifierKeys keys)
keys
- public long getKeys()