Class KeyCodeCombination
public final class KeyCodeCombination
extends KeyCombination KeyCode. Such key combination is independent on the keyboard functional layout configured by the user at the time of key combination matching.- Since:
- JavaFX 2.0
Nested Class Summary
Nested classes/interfaces declared in class javafx.scene.input.KeyCombination
KeyCombination.Modifier, KeyCombination.ModifierValue
Field Summary
Fields declared in class javafx.scene.input.KeyCombination
ALT_ANY, ALT_DOWN, CONTROL_ANY, CONTROL_DOWN, META_ANY, META_DOWN, NO_MATCH, SHIFT_ANY, SHIFT_DOWN, SHORTCUT_ANY, SHORTCUT_DOWN
Constructor Summary
| Constructor | Description |
|---|---|
KeyCodeCombination(KeyCode code,
KeyCombination.Modifier... modifiers) | Constructs a KeyCodeCombination for the specified main key and with the specified list of modifiers. |
KeyCodeCombination(KeyCode code,
KeyCombination.ModifierValue shift,
KeyCombination.ModifierValue control,
KeyCombination.ModifierValue alt,
KeyCombination.ModifierValue meta,
KeyCombination.ModifierValue shortcut) | Constructs a KeyCodeCombination for the specified main key and with an explicit specification of all modifier keys. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
boolean | equals(Object obj) | Tests whether this KeyCodeCombination equals to the specified object. |
KeyCode | getCode() | Gets the key code associated with this key combination. |
String | getName() | Returns a string representation of this KeyCodeCombination. |
int | hashCode() | Returns a hash code value for this KeyCodeCombination. |
boolean | match(KeyEvent event) | Tests whether this key combination matches the key combination in the given KeyEvent. |
Methods declared in class javafx.scene.input.KeyCombination
getAlt, getControl, getDisplayText, getMeta, getShift, getShortcut, keyCombination, toString, valueOf
Constructor Details
KeyCodeCombination
public KeyCodeCombination(KeyCode code, KeyCombination.ModifierValue shift, KeyCombination.ModifierValue control, KeyCombination.ModifierValue alt, KeyCombination.ModifierValue meta, KeyCombination.ModifierValue shortcut)
KeyCodeCombination for the specified main key and with an explicit specification of all modifier keys. Each modifier key can be set to PRESSED, RELEASED or IGNORED.- Parameters:
-
code- the key code of the main key -
shift- the value of theshiftmodifier key -
control- the value of thecontrolmodifier key -
alt- the value of thealtmodifier key -
meta- the value of themetamodifier key -
shortcut- the value of theshortcutmodifier key
KeyCodeCombination
public KeyCodeCombination(KeyCode code, KeyCombination.Modifier... modifiers)
KeyCodeCombination for the specified main key and with the specified list of modifiers. All modifier keys which are not explicitly listed are set to the default RELEASED value. All possible modifiers which change the default modifier value are defined as constants in the KeyCombination class.
- Parameters:
-
code- the key code of the main key -
modifiers- the list of modifier keys and their corresponding values
Method Details
getCode
public final KeyCode getCode()
- Returns:
- The key code associated with this key combination
match
public boolean match(KeyEvent event)
KeyEvent. It uses only the key code and the state of the modifier keys from the KeyEvent in the test. This means that the method can return true only for KEY_PRESSED and KEY_RELEASED events, but not for KEY_TYPED events, which don't have valid key codes.- Overrides:
-
matchin classKeyCombination - Parameters:
-
event- the key event - Returns:
-
trueif the key combinations match,falseotherwise
getName
public String getName()
KeyCodeCombination. The string representation consists of sections separated by plus characters. Each section specifies either a modifier key or the main key.
A modifier key section contains the KeyCode name of a modifier key. It can be prefixed with the Ignored keyword. A non-prefixed modifier key implies its PRESSED value while the prefixed version implies the IGNORED value. If some modifier key is not specified in the string at all, it means it has the default RELEASED value.
The main key section contains the key code name of the main key and is the last section in the returned string.
- Overrides:
-
getNamein classKeyCombination - Returns:
- the string representation of this
KeyCodeCombination
equals
public boolean equals(Object obj)
KeyCodeCombination equals to the specified object.- Overrides:
-
equalsin classKeyCombination - Parameters:
-
obj- the object to compare to - Returns:
-
trueif the objects are equal,falseotherwise
hashCode
public int hashCode()
KeyCodeCombination.- Overrides:
-
hashCodein classKeyCombination - Returns:
- the hash code value
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.