key code
or key character, the latter must match values returned by KeyEvent#getCharacter().
A modifier key is shift, control, alt, meta or shortcut.
This class also provides a set of convenience methods for refering to keys found on macOS platform.
| Modifier and Type | Class and Description |
|---|---|
| public static class | KeyBinding.
A builder for |
| private static enum | KeyBinding.
Condition used to build input key mappings. |
| Modifier and Type | Field and Description |
|---|---|
| private final Object | |
| private final EnumSet |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static KeyBinding | |
| public static KeyBinding. | |
| public static KeyBinding. | |
| public static KeyBinding | |
| public static KeyBinding | |
| public static KeyBinding | Returns: the KeyBindingthe key code code)Creates a KeyBinding which corresponds to the key press with the specified |
| private static KeyBinding | |
| public boolean | equals(Object
the reference object with which to compare. x)Overrides java. Indicates whether some other object is "equal to" this one. |
| pack-priv static KeyBinding | |
| public KeyCode | Returns: key code, or nullReturns the |
| public int | |
| public boolean | Returns: true if this key binding if for the key press eventDetermines whether this key binding if for the key pressed event. |
| public boolean | Returns: true if this key binding if for the key release eventDetermines whether this key binding if for the key released event. |
| public boolean | Returns: true if this key binding if for the key typed eventDetermines whether this key binding if for the key typed event. |
| public static KeyBinding | |
| public static KeyBinding | |
| public static KeyBinding | |
| public static KeyBinding | Returns: the KeyBinding, or nullthe key code code)Creates a KeyBinding which corresponds to the key press with the specified |
| public static KeyBinding | Returns: the KeyBinding, or nullthe key code code)Creates a KeyBinding which corresponds to the key press with the specified |
| public static KeyBinding | |
| public String | |
| public KeyBinding | Returns: the KeyBindingthe key code newCode)Creates a new instance of |
| key | back to summary |
|---|---|
| private final Object key | |
| modifiers | back to summary |
|---|---|
| private final EnumSet<KeyBinding. | |
| KeyBinding | back to summary |
|---|---|
| private KeyBinding(Object key, EnumSet<KeyBinding. | |
| alt | back to summary |
|---|---|
| public static KeyBinding alt(KeyCode code) Creates a KeyBinding which corresponds to the key press with the specified
This method is equivalent to
| |
| builder | back to summary |
|---|---|
| public static KeyBinding. Creates a
| |
| builder | back to summary |
|---|---|
| public static KeyBinding. Creates a
| |
| command | back to summary |
|---|---|
| public static KeyBinding command(KeyCode code) This utility method creates a
This method returns
| |
| control | back to summary |
|---|---|
| public static KeyBinding control(KeyCode code) Creates a KeyBinding which corresponds to the key press with the specified
| |
| controlShift | back to summary |
|---|---|
| public static KeyBinding controlShift(KeyCode code) Creates a KeyBinding which corresponds to the key press with the specified
| |
| create | back to summary |
|---|---|
| private static KeyBinding create(Object key, KeyBinding. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object x) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| from | back to summary |
|---|---|
| pack-priv static KeyBinding from(KeyEvent ev) Creates a KeyBinding from a KeyEvent, or a null if the event does not correspond to a valid KeyBinding.
| |
| getKeyCode | back to summary |
|---|---|
| public KeyCode getKeyCode() Returns the
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isKeyPressed | back to summary |
|---|---|
| public boolean isKeyPressed() Determines whether this key binding if for the key pressed event.
| |
| isKeyReleased | back to summary |
|---|---|
| public boolean isKeyReleased() Determines whether this key binding if for the key released event.
| |
| isKeyTyped | back to summary |
|---|---|
| public boolean isKeyTyped() Determines whether this key binding if for the key typed event.
| |
| of | back to summary |
|---|---|
| public static KeyBinding of(KeyCode code) Creates a
| |
| option | back to summary |
|---|---|
| public static KeyBinding option(KeyCode code) Creates a KeyBinding which corresponds to the key press with the specified
This method returns
| |
| shift | back to summary |
|---|---|
| public static KeyBinding shift(KeyCode code) Creates a KeyBinding which corresponds to the key press with the specified
| |
| shiftOption | back to summary |
|---|---|
| public static KeyBinding shiftOption(KeyCode code) Creates a KeyBinding which corresponds to the key press with the specified
This method returns
| |
| shiftShortcut | back to summary |
|---|---|
| public static KeyBinding shiftShortcut(KeyCode code) Creates a KeyBinding which corresponds to the key press with the specified
| |
| shortcut | back to summary |
|---|---|
| public static KeyBinding shortcut(KeyCode code) Creates a KeyBinding which corresponds to the key press with the specified
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| withNewKeyCode | back to summary |
|---|---|
| public KeyBinding withNewKeyCode(KeyCode newCode) Creates a new instance of
| |
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()
| Modifier and Type | Field and Description |
|---|---|
| private final Object | |
| private final EnumSet |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public KeyBinding. | |
| public KeyBinding | Returns: a new key binding instance.Creates a new |
| public KeyBinding. | |
| public KeyBinding. | |
| private KeyBinding. | |
| public KeyBinding. | Returns: the Builder instanceSets the KEY_RELEASED condition, clearing KEY_PRESSED and KEY_TYPED. |
| public KeyBinding. | Returns: the Builder instanceSets the KEY_TYPED condition, clearing KEY_PRESSED and KEY_RELEASED. |
| public KeyBinding. | |
| public KeyBinding. | |
| private void | |
| public KeyBinding. | |
| public KeyBinding. |
| key | back to summary |
|---|---|
| private final Object key | |
| m | back to summary |
|---|---|
| private final EnumSet<KeyBinding. | |
| Builder | back to summary |
|---|---|
| pack-priv Builder(Object key) Constructs a Builder | |
| alt | back to summary |
|---|---|
| public KeyBinding. Sets the
| |
| build | back to summary |
|---|---|
| public KeyBinding build() Creates a new
| |
| command | back to summary |
|---|---|
| public KeyBinding. Sets the
Setting this condition on non-macOS platforms will result in the
| |
| control | back to summary |
|---|---|
| public KeyBinding. Sets the
| |
| init | back to summary |
|---|---|
| private KeyBinding. | |
| keyReleased | back to summary |
|---|---|
| public KeyBinding. Sets the KEY_RELEASED condition, clearing KEY_PRESSED and KEY_TYPED.
| |
| keyTyped | back to summary |
|---|---|
| public KeyBinding. Sets the KEY_TYPED condition, clearing KEY_PRESSED and KEY_RELEASED.
| |
| meta | back to summary |
|---|---|
| public KeyBinding. Sets the
| |
| option | back to summary |
|---|---|
| public KeyBinding. Sets the
Setting this condition on non-macOS platforms will result in the
| |
| replace | back to summary |
|---|---|
| private void replace(KeyBinding. | |
| shift | back to summary |
|---|---|
| public KeyBinding. Sets the
| |
| shortcut | back to summary |
|---|---|
| public KeyBinding. Sets the
| |
The KCondition values are used as keys in a hash table, so when the platform sends a key event with multiple modifiers, some modifiers are dropped in order to make the final key binding to function lookup unambiguous.
The mapping is as follows:
KCondition Mac Windows/Linux ALT OPTION ALT COMMAND COMMAND (ignored) CTRL CTRL CTRL META COMMAND META OPTION OPTION (ignored) SHIFT SHIFT SHIFT SHORTCUT COMMAND CTRL WINDOWS (ignored) META
| Modifier and Type | Field and Description |
|---|---|
| public static final KeyBinding. | ALT
ALT modifier, mapped to OPTION on Mac, ALT on Windows/Linux |
| public static final KeyBinding. | COMMAND
COMMAND modifier, mapped to COMMAND on Mac only |
| public static final KeyBinding. | CTRL
CTRL modifier |
| public static final KeyBinding. | KEY_PRESSED
a key pressed event |
| public static final KeyBinding. | KEY_RELEASED
a key released event |
| public static final KeyBinding. | KEY_TYPED
a key typed event |
| public static final KeyBinding. | META
META modifier, mapped to COMMAND on Mac, META on Windows/Linux |
| public static final KeyBinding. | OPTION
OPTION modifier, mapped to OPTION on Mac only |
| public static final KeyBinding. | SHIFT
SHIFT modifier |
| public static final KeyBinding. | SHORTCUT
SHORTCUT modifier, mapped to COMMAND on Mac, CTRL on Windows/Linux |
| public static final KeyBinding. | WINDOWS
Windows key modifier (⊞), mapped to WINDOWS on Windows only |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static KeyBinding. | |
| public static KeyBinding. |
| ALT | back to summary |
|---|---|
| public static final KeyBinding. ALT modifier, mapped to OPTION on Mac, ALT on Windows/Linux | |
| COMMAND | back to summary |
|---|---|
| public static final KeyBinding. COMMAND modifier, mapped to COMMAND on Mac only | |
| CTRL | back to summary |
|---|---|
| public static final KeyBinding. CTRL modifier | |
| KEY_PRESSED | back to summary |
|---|---|
| public static final KeyBinding. a key pressed event | |
| KEY_RELEASED | back to summary |
|---|---|
| public static final KeyBinding. a key released event | |
| KEY_TYPED | back to summary |
|---|---|
| public static final KeyBinding. a key typed event | |
| META | back to summary |
|---|---|
| public static final KeyBinding. META modifier, mapped to COMMAND on Mac, META on Windows/Linux | |
| OPTION | back to summary |
|---|---|
| public static final KeyBinding. OPTION modifier, mapped to OPTION on Mac only | |
| SHIFT | back to summary |
|---|---|
| public static final KeyBinding. SHIFT modifier | |
| SHORTCUT | back to summary |
|---|---|
| public static final KeyBinding. SHORTCUT modifier, mapped to COMMAND on Mac, CTRL on Windows/Linux | |
| WINDOWS | back to summary |
|---|---|
| public static final KeyBinding. Windows key modifier (⊞), mapped to WINDOWS on Windows only | |
| KCondition | back to summary |
|---|---|
| private KCondition() | |
| valueOf | back to summary |
|---|---|
| public static KeyBinding. | |
| values | back to summary |
|---|---|
| public static KeyBinding. | |