Class KeyCodeCombination

  • public final class KeyCodeCombination
    extends KeyCombination
    This class represents a key combination in which the main key is specified by its KeyCode. Such key combination is independent on the keyboard functional layout configured by the user at the time of key combination matching.
    JavaFX 2.0
    • Constructor Detail

      • KeyCodeCombination

        public KeyCodeCombination​(KeyCode code,
                                  KeyCombination.Modifier... modifiers)
        Constructs a 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.

        code - the key code of the main key
        modifiers - the list of modifier keys and their corresponding values
    • Method Detail

      • getCode

        public final KeyCode getCode()
        Gets the key code associated with this key combination.
        The key code associated with this key combination
      • match

        public boolean match​(KeyEvent event)
        Tests whether this key combination matches the key combination in the given 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.
        match in class KeyCombination
        event - the key event
        true if the key combinations match, false otherwise
      • getName

        public String getName()
        Returns a string representation of this 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.

        getName in class KeyCombination
        the string representation of this KeyCodeCombination
      • getDisplayText

        public String getDisplayText()
        Returns a string representation of this KeyCombination that is suitable for display in a user interface (for example, beside a menu item).
        getDisplayText in class KeyCombination
        A string representation of this KeyCombination, suitable for display in a user interface.
      • equals

        public boolean equals​(Object obj)
        Tests whether this KeyCodeCombination equals to the specified object.
        equals in class KeyCombination
        obj - the object to compare to
        true if the objects are equal, false otherwise
      • hashCode

        public int hashCode()
        Returns a hash code value for this KeyCodeCombination.
        hashCode in class KeyCombination
        the hash code value