- Direct Known Subclasses:
- KeyCharacterCombination,- KeyCodeCombination
KeyCodeCombination or key
 character - KeyCharacterCombination. A modifier key is shift,
 control, alt, meta or shortcut and can be
 defined as DOWN, UP or ANY.
 
 The shortcut modifier is used to represent the modifier key which is
 used commonly in keyboard shortcuts on the host platform. This is for
 example control on Windows and meta (command key) on Mac.
 By using shortcut key modifier developers can create platform
 independent shortcuts. So the "Shortcut+C" key combination is handled
 internally as "Ctrl+C" on Windows and "Meta+C" on Mac.
- Since:
- JavaFX 2.0
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final classThis class represents a pair of modifier key and its value.static enumModifierValuespecifies state of modifier keys.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final KeyCombination.ModifierModifier which specifies that thealtkey can be either up or down.static final KeyCombination.ModifierModifier which specifies that thealtkey must be down.static final KeyCombination.ModifierModifier which specifies that thecontrolkey can be either up or down.static final KeyCombination.ModifierModifier which specifies that thecontrolkey must be down.static final KeyCombination.ModifierModifier which specifies that themetakey can be either up or down.static final KeyCombination.ModifierModifier which specifies that themetakey must be down.static final KeyCombinationA KeyCombination that will match with no events.static final KeyCombination.ModifierModifier which specifies that theshiftkey can be either up or down.static final KeyCombination.ModifierModifier which specifies that theshiftkey must be down.static final KeyCombination.ModifierModifier which specifies that theshortcutkey can be either up or down.static final KeyCombination.ModifierModifier which specifies that theshortcutkey must be down.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedKeyCombination(KeyCombination.Modifier... modifiers) Constructs aKeyCombinationwith the specified list of modifiers.protectedKeyCombination(KeyCombination.ModifierValue shift, KeyCombination.ModifierValue control, KeyCombination.ModifierValue alt, KeyCombination.ModifierValue meta, KeyCombination.ModifierValue shortcut) Constructs aKeyCombinationwith an explicit specification of all modifier keys.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanTests whether thisKeyCombinationequals to the specified object.getAlt()The state of thealtkey in this key combination.The state of thecontrolkey in this key combination.Returns a string representation of thisKeyCombinationthat is suitable for display in a user interface (for example, beside a menu item).getMeta()The state of themetakey in this key combination.getName()Returns a string representation of thisKeyCombination.getShift()The state of theshiftkey in this key combination.The state of theshortcutkey in this key combination.inthashCode()Returns a hash code value for thisKeyCombination.static KeyCombinationkeyCombination(String name) Constructs a newKeyCombinationfrom the specified string.booleanTests whether this key combination matches the combination in the givenKeyEvent.toString()Returns a string representation of this object.static KeyCombinationConstructs a newKeyCombinationfrom the specified string.
- 
Field Details- 
SHIFT_DOWNModifier which specifies that theshiftkey must be down.
- 
SHIFT_ANYModifier which specifies that theshiftkey can be either up or down.
- 
CONTROL_DOWNModifier which specifies that thecontrolkey must be down.
- 
CONTROL_ANYModifier which specifies that thecontrolkey can be either up or down.
- 
ALT_DOWNModifier which specifies that thealtkey must be down.
- 
ALT_ANYModifier which specifies that thealtkey can be either up or down.
- 
META_DOWNModifier which specifies that themetakey must be down.
- 
META_ANYModifier which specifies that themetakey can be either up or down.
- 
SHORTCUT_DOWNModifier which specifies that theshortcutkey must be down.
- 
SHORTCUT_ANYModifier which specifies that theshortcutkey can be either up or down.
- 
NO_MATCHA KeyCombination that will match with no events.
 
- 
- 
Constructor Details- 
KeyCombinationprotected KeyCombination(KeyCombination.ModifierValue shift, KeyCombination.ModifierValue control, KeyCombination.ModifierValue alt, KeyCombination.ModifierValue meta, KeyCombination.ModifierValue shortcut) Constructs aKeyCombinationwith an explicit specification of all modifier keys. Each modifier key can be set toDOWN,UPorANY.- Parameters:
- shift- the value of the- shiftmodifier key
- control- the value of the- controlmodifier key
- alt- the value of the- altmodifier key
- meta- the value of the- metamodifier key
- shortcut- the value of the- shortcutmodifier key
 
- 
KeyCombinationConstructs aKeyCombinationwith the specified list of modifiers. All modifier keys which are not explicitly listed are set to the defaultUPvalue.All possible modifiers which change the default modifier value are defined as constants in the KeyCombinationclass.- Parameters:
- modifiers- the list of modifier keys and their corresponding values
 
 
- 
- 
Method Details- 
getShiftThe state of theshiftkey in this key combination.- Returns:
- The state of the shiftkey in this key combination
 
- 
getControlThe state of thecontrolkey in this key combination.- Returns:
- The state of the controlkey in this key combination
 
- 
getAltThe state of thealtkey in this key combination.- Returns:
- The state of the altkey in this key combination.
 
- 
getMetaThe state of themetakey in this key combination.- Returns:
- The state of the metakey in this key combination
 
- 
getShortcutThe state of theshortcutkey in this key combination.- Returns:
- The state of the shortcutkey in this key combination
 
- 
matchTests whether this key combination matches the combination in the givenKeyEvent.The implementation of this method in the KeyCombinationclass does only a partial test with the modifier keys. This method is overridden in subclasses to include the main key in the test.- Parameters:
- event- the key event
- Returns:
- trueif the key combinations match,- falseotherwise
 
- 
getNameReturns a string representation of thisKeyCombination.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 KeyCodename of a modifier key. It can be prefixed with theIgnoredkeyword. A non-prefixed modifier key implies itsDOWNvalue while the prefixed version implies theANY(ignored) value. If some modifier key is not specified in the string at all, it means it has the defaultUPvalue.The format of the main key section of the key combination string depends on the KeyCombinationsubclass. It is either the key code name forKeyCodeCombinationor the single quoted key character forKeyCharacterCombination.Examples of KeyCombinationstring representations:"Ctrl+Alt+Q" "Ignore Shift+Ctrl+A" "Alt+'w'" - Returns:
- the string representation of this KeyCombination
 
- 
getDisplayTextReturns a string representation of thisKeyCombinationthat is suitable for display in a user interface (for example, beside a menu item).- Returns:
- A string representation of this KeyCombination, suitable for display in a user interface.
- Since:
- JavaFX 8u20
 
- 
equalsTests whether thisKeyCombinationequals to the specified object.
- 
hashCodepublic int hashCode()Returns a hash code value for thisKeyCombination.
- 
toStringReturns a string representation of this object. Implementation returns the result of thegetName()call.
- 
valueOfConstructs a newKeyCombinationfrom the specified string. The string should be in the same format as produced by thegetNamemethod.If the main key section string is quoted in single quotes the method creates a new KeyCharacterCombinationfor the unquoted substring. Otherwise it finds the key code which name corresponds to the main key section string and creates aKeyCodeCombinationfor it. If this can't be done, it falls back to theKeyCharacterCombination.- Parameters:
- value- the string which represents the requested key combination
- Returns:
- the constructed KeyCombination
- Since:
- JavaFX 2.1
 
- 
keyCombinationConstructs a newKeyCombinationfrom the specified string. This method simply delegates tovalueOf(String).- Parameters:
- name- the string which represents the requested key combination
- Returns:
- the constructed KeyCombination
- See Also:
 
 
-