Class KeyEvent2
java.lang.Object
com.realtime.crossfire.jxclient.gui.keybindings.KeyEvent2
- All Implemented Interfaces:
Comparable<KeyEvent2>
Represents a pressed or released key.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe mask for "shift".static final intThe mask for "alt_graph".static final intThe mask for "ctrl".static final intThe mask for all used modifiers.static final intThe mask for "meta".static final intThe mask for "no modifier".static final intThe mask for "shift". -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintstatic intconvertModifiers(int modifiers) Converts old-style modifiers into the current format.booleancharReturns the key as a char.intReturns the key code.intReturns the modifiers.inthashCode()booleanmatchesKeyEvent(@NotNull KeyEvent2 keyEvent) Returns whether this key event matches the same key code as another key event.static @NotNull StringmodifiersToString(int modifiers) Converts modifiers to string representation.static intstringToModifiers(@NotNull String modifiers) Converts a string representation to modifiers.@NotNull StringtoString()
-
Field Details
-
NONE
public static final int NONEThe mask for "no modifier".- See Also:
-
ALT
public static final int ALTThe mask for "shift".- See Also:
-
ALT_GRAPH
public static final int ALT_GRAPHThe mask for "alt_graph".- See Also:
-
CTRL
public static final int CTRLThe mask for "ctrl".- See Also:
-
META
public static final int METAThe mask for "meta".- See Also:
-
SHIFT
public static final int SHIFTThe mask for "shift".- See Also:
-
MASK
public static final int MASKThe mask for all used modifiers.- See Also:
-
-
Constructor Details
-
KeyEvent2
public KeyEvent2(int keyCode, char keyChar, int modifiers) Creates a new instance.- Parameters:
keyCode- the key codekeyChar- the key as a charmodifiers- the modifiers
-
-
Method Details
-
getKeyCode
public int getKeyCode()Returns the key code. SeeVK_xxxconstants.- 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
-
matchesKeyEvent
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
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<KeyEvent2>
-
toString
-
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
Converts modifiers to string representation.- Parameters:
modifiers- the modifiers- Returns:
- the string representation
-
stringToModifiers
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
-