java.lang.Object
com.realtime.crossfire.jxclient.gui.keybindings.KeyEvent2
All Implemented Interfaces:
Comparable<KeyEvent2>

public class KeyEvent2 extends Object implements Comparable<KeyEvent2>
Represents a pressed or released key.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The mask for "shift".
    static final int
    The mask for "alt_graph".
    static final int
    The mask for "ctrl".
    static final int
    The mask for all used modifiers.
    static final int
    The mask for "meta".
    static final int
    The mask for "no modifier".
    static final int
    The mask for "shift".
  • Constructor Summary

    Constructors
    Constructor
    Description
    KeyEvent2(int keyCode, char keyChar, int modifiers)
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    compareTo(@NotNull KeyEvent2 o)
     
    static int
    convertModifiers(int modifiers)
    Converts old-style modifiers into the current format.
    boolean
    equals(@Nullable Object obj)
     
    char
    Returns the key as a char.
    int
    Returns the key code.
    int
    Returns the modifiers.
    int
     
    boolean
    matchesKeyEvent(@NotNull KeyEvent2 keyEvent)
    Returns whether this key event matches the same key code as another key event.
    static @NotNull String
    modifiersToString(int modifiers)
    Converts modifiers to string representation.
    static int
    stringToModifiers(@NotNull String modifiers)
    Converts a string representation to modifiers.
    @NotNull String
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • KeyEvent2

      public KeyEvent2(int keyCode, char keyChar, int modifiers)
      Creates a new instance.
      Parameters:
      keyCode - the key code
      keyChar - the key as a char
      modifiers - the modifiers
  • Method Details

    • getKeyCode

      public int getKeyCode()
      Returns the key code. See VK_xxx constants.
      Returns:
      the key code
    • getKeyChar

      public char getKeyChar()
      Returns the key as a char.
      Returns:
      the key as a char
    • getModifiers

      public int getModifiers()
      Returns the modifiers. A combination of ALT, ALT_GRAPH, CTRL, META, and SHIFT.
      Returns:
      the modifiers
    • matchesKeyEvent

      public boolean matchesKeyEvent(@NotNull @NotNull KeyEvent2 keyEvent)
      Returns whether this key event matches the same key code as another key event.
      Parameters:
      keyEvent - the other key event
      Returns:
      whether both instances match the same key code
    • equals

      public boolean equals(@Nullable @Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(@NotNull @NotNull KeyEvent2 o)
      Specified by:
      compareTo in interface Comparable<KeyEvent2>
    • toString

      @NotNull public @NotNull String toString()
      Overrides:
      toString in class Object
    • convertModifiers

      public static int convertModifiers(int modifiers)
      Converts old-style modifiers into the current format.
      Parameters:
      modifiers - the old-style modifiers
      Returns:
      the current format
    • modifiersToString

      @NotNull public static @NotNull String modifiersToString(int modifiers)
      Converts modifiers to string representation.
      Parameters:
      modifiers - the modifiers
      Returns:
      the string representation
    • stringToModifiers

      public static int stringToModifiers(@NotNull @NotNull String modifiers)
      Converts a string representation to modifiers. If the string representation is invalid, a warning is printed and the invalid part is ignored.
      Parameters:
      modifiers - the string representation
      Returns:
      the modifiers