Class Keyboard.KeyStroke

  • Enclosing class:
    Keyboard

    public static final class Keyboard.KeyStroke
    extends java.lang.Object
    Represents a keystroke, a combination of a keycode and modifier flags.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String COMMAND_ABBREVIATION  
    • Constructor Summary

      Constructors 
      Constructor Description
      KeyStroke​(int code, int modifiers)
      Construct from a key code and the bit mask of the desired modifiers.
    • Field Detail

      • COMMAND_ABBREVIATION

        public static final java.lang.String COMMAND_ABBREVIATION
        See Also:
        Constant Field Values
    • Constructor Detail

      • KeyStroke

        public KeyStroke​(int code,
                         int modifiers)
        Construct from a key code and the bit mask of the desired modifiers.
        Parameters:
        code - The key code desired.
        modifiers - The bit mask of modifiers to use.
        See Also:
        Keyboard.KeyCode, Keyboard.Modifier
    • Method Detail

      • getKeyCode

        public int getKeyCode()
        Returns:
        The key code associated with this keystroke.
      • getModifiers

        public int getModifiers()
        Returns:
        The bit mask of modifiers associated with this keystroke.
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • decode

        public static Keyboard.KeyStroke decode​(java.lang.String value)
        Decode a keystroke value from its string representation.
        Parameters:
        value - Input value, such as "Cmd-F1", "Ctrl+Shift+Left", or even "⌃⌘F1".
        Returns:
        The corresponding KeyStroke value.
        Throws:
        java.lang.IllegalArgumentException - if the input string cannot be decoded.