Class KeyboardHelper
java.lang.Object
eu.svjatoslav.sixth.e3d.gui.humaninput.KeyboardHelper
Utility class providing keyboard key code constants and modifier detection methods.
Provides named constants for common key codes and static helper methods to check whether modifier keys (Ctrl, Alt, Shift) are pressed in a given event modifier mask.
Usage example:
public boolean keyPressed(KeyEvent event, ViewPanel viewPanel) {
if (event.getKeyCode() == KeyboardHelper.ENTER) {
// Handle Enter key
}
if (KeyboardHelper.isCtrlPressed(event.getModifiersEx())) {
// Handle Ctrl+key combination
}
return true;
}
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intKey code for the Backspace key.static final intKey code for the Delete key.static final intKey code for the Down arrow key.static final intKey code for the End key.static final intKey code for the Enter/Return key.static final intKey code for the Escape key.static final intKey code for the Home key.static final intKey code for the Left arrow key.static final intKey code for the Page Down key.static final intKey code for the Page Up key.static final intKey code for the Right arrow key.static final intKey code for the Shift key.static final intKey code for the Tab key.static final intKey code for the Up arrow key. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisAltPressed(int modifiersEx) Checks if the Alt key is pressed in the given modifier mask.static booleanisCtrlPressed(int modifiersEx) Checks if the Ctrl key is pressed in the given modifier mask.static booleanisShiftPressed(int modifiersEx) Checks if the Shift key is pressed in the given modifier mask.static booleanisText(int keyCode) Determines whether the given key code represents a text-producing key (as opposed to navigation or modifier keys like arrows, Shift, Escape).
-
Field Details
-
TAB
public static final int TABKey code for the Tab key.- See Also:
-
DOWN
public static final int DOWNKey code for the Down arrow key.- See Also:
-
UP
public static final int UPKey code for the Up arrow key.- See Also:
-
RIGHT
public static final int RIGHTKey code for the Right arrow key.- See Also:
-
LEFT
public static final int LEFTKey code for the Left arrow key.- See Also:
-
PGDOWN
public static final int PGDOWNKey code for the Page Down key.- See Also:
-
PGUP
public static final int PGUPKey code for the Page Up key.- See Also:
-
HOME
public static final int HOMEKey code for the Home key.- See Also:
-
END
public static final int ENDKey code for the End key.- See Also:
-
DEL
public static final int DELKey code for the Delete key.- See Also:
-
ENTER
public static final int ENTERKey code for the Enter/Return key.- See Also:
-
BACKSPACE
public static final int BACKSPACEKey code for the Backspace key.- See Also:
-
ESC
public static final int ESCKey code for the Escape key.- See Also:
-
SHIFT
public static final int SHIFTKey code for the Shift key.- See Also:
-
-
Constructor Details
-
KeyboardHelper
public KeyboardHelper()
-
-
Method Details
-
isAltPressed
public static boolean isAltPressed(int modifiersEx) Checks if the Alt key is pressed in the given modifier mask.- Parameters:
modifiersEx- the extended modifier mask fromInputEvent.getModifiersEx()- Returns:
trueif Alt is pressed
-
isCtrlPressed
public static boolean isCtrlPressed(int modifiersEx) Checks if the Ctrl key is pressed in the given modifier mask.- Parameters:
modifiersEx- the extended modifier mask fromInputEvent.getModifiersEx()- Returns:
trueif Ctrl is pressed
-
isShiftPressed
public static boolean isShiftPressed(int modifiersEx) Checks if the Shift key is pressed in the given modifier mask.- Parameters:
modifiersEx- the extended modifier mask fromInputEvent.getModifiersEx()- Returns:
trueif Shift is pressed
-
isText
public static boolean isText(int keyCode) Determines whether the given key code represents a text-producing key (as opposed to navigation or modifier keys like arrows, Shift, Escape).- Parameters:
keyCode- the key code to check- Returns:
trueif the key produces text input
-