KeyCharacterCombination (JavaFX 27)
Description: declaration: module: javafx.graphics, package: javafx.scene.input, class: KeyCharacterCombination

# Class KeyCharacterCombination

java.lang.Object
javafx.scene.input.KeyCombination
javafx.scene.input.KeyCharacterCombination

public final class KeyCharacterCombination extends KeyCombination
This class represents a key combination in which the main key is specified by its character. This is the preferred way to specify a shortcut involving a symbol or punctuation.

The location of a symbol or punctuation mark can vary from one keyboard layout to another. For example, on an English QWERTY layout the '+' symbol is the shifted character on `KeyCode.EQUALS` but on a German layout it is the unmodified character on `KeyCode.PLUS`. The '+' symbol also appears as `KeyCode.ADD` on the numeric keypad. When matching against a key event a key character combination queries the OS to determine which keys the character appears on in the current layout.

Since:
  JavaFX 2.0

- ## Nested Class Summary

  ### Nested classes/interfaces declared in class KeyCombination

  `KeyCombination.Modifier, KeyCombination.ModifierValue`

- ## Field Summary

  ### Fields declared in class 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

  Constructors
  Constructor
  Description
  `KeyCharacterCombination(String character, KeyCombination.Modifier... modifiers)`
  Constructs a `KeyCharacterCombination` for the specified main key character and the specified list of modifiers.
  `KeyCharacterCombination(String character, KeyCombination.ModifierValue shift, KeyCombination.ModifierValue control, KeyCombination.ModifierValue alt, KeyCombination.ModifierValue meta, KeyCombination.ModifierValue shortcut)`
  Constructs a `KeyCharacterCombination` for the specified main key character and with an explicit specification of all modifier keys.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  Tests whether this `KeyCharacterCombination` equals to the specified object.
  `final String`
  `getCharacter()`
  Gets the key character associated with this key combination.
  `String`
  `getName()`
  Returns a string representation of this `KeyCharacterCombination`.
  `int`
  `hashCode()`
  Returns a hash code value for this `KeyCharacterCombination`.
  `boolean`
  `match(KeyEvent event)`
  Tests whether this key combination matches the key combination in the given `KeyEvent`.

  ### Methods declared in class KeyCombination

  `getAlt, getControl, getDisplayText, getMeta, getShift, getShortcut, keyCombination, toString, valueOf`

  ### Methods declared in class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### KeyCharacterCombination

    public KeyCharacterCombination(String character, KeyCombination.ModifierValue shift, KeyCombination.ModifierValue control, KeyCombination.ModifierValue alt, KeyCombination.ModifierValue meta, KeyCombination.ModifierValue shortcut)
    Constructs a `KeyCharacterCombination` for the specified main key character and with an explicit specification of all modifier keys. Each modifier key can be set to `PRESSED`, `RELEASED` or `IGNORED`.
    Parameters:
      `character` - the main key character
      `shift` - the value of the `shift` modifier key
      `control` - the value of the `control` modifier key
      `alt` - the value of the `alt` modifier key
      `meta` - the value of the `meta` modifier key
      `shortcut` - the value of the `shortcut` modifier key

  - ### KeyCharacterCombination

    public KeyCharacterCombination(String character, KeyCombination.Modifier... modifiers)
    Constructs a `KeyCharacterCombination` for the specified main key character and 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:
      `character` - the main key character
      `modifiers` - the list of modifier keys and their corresponding values

- ## Method Details

  - ### getCharacter

    public final String getCharacter()
    Gets the key character associated with this key combination.
    Returns:
      The key character associated with this key combination

  - ### match

    public boolean match(KeyEvent event)
    Tests whether this key combination matches the key combination in the given `KeyEvent`. The key character of this object is first translated to the key codes which are capable of producing the character in the current keyboard layout and then the resulting key codes together with the modifier keys are matched against the key code and key modifiers from the `KeyEvent`. 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:
      `match` in class `KeyCombination`
    Parameters:
      `event` - the key event
    Returns:
      `true` if the key combinations match, `false` otherwise

  - ### getName

    public String getName()
    Returns a string representation of this `KeyCharacterCombination`.

    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 main key character enclosed in single quotes and is the last section in the returned string.

    Overrides:
      `getName` in class `KeyCombination`
    Returns:
      the string representation of this `KeyCharacterCombination`

  - ### equals

    public boolean equals(Object obj)
    Tests whether this `KeyCharacterCombination` equals to the specified object.
    Overrides:
      `equals` in class `KeyCombination`
    Parameters:
      `obj` - the object to compare to
    Returns:
      `true` if the objects are equal, `false` otherwise

  - ### hashCode

    public int hashCode()
    Returns a hash code value for this `KeyCharacterCombination`.
    Overrides:
      `hashCode` in class `KeyCombination`
    Returns:
      the hash code value