Class KeyboardHelper

java.lang.Object
eu.svjatoslav.sixth.e3d.gui.humaninput.KeyboardHelper

public class KeyboardHelper extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Key code for the Backspace key.
    static final int
    Key code for the Delete key.
    static final int
    Key code for the Down arrow key.
    static final int
    Key code for the End key.
    static final int
    Key code for the Enter/Return key.
    static final int
    Key code for the Escape key.
    static final int
    Key code for the Home key.
    static final int
    Key code for the Left arrow key.
    static final int
    Key code for the Page Down key.
    static final int
    Key code for the Page Up key.
    static final int
    Key code for the Right arrow key.
    static final int
    Key code for the Shift key.
    static final int
    Key code for the Tab key.
    static final int
    Key code for the Up arrow key.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    isAltPressed(int modifiersEx)
    Checks if the Alt key is pressed in the given modifier mask.
    static boolean
    isCtrlPressed(int modifiersEx)
    Checks if the Ctrl key is pressed in the given modifier mask.
    static boolean
    isShiftPressed(int modifiersEx)
    Checks if the Shift key is pressed in the given modifier mask.
    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).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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 from InputEvent.getModifiersEx()
      Returns:
      true if 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 from InputEvent.getModifiersEx()
      Returns:
      true if 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 from InputEvent.getModifiersEx()
      Returns:
      true if 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:
      true if the key produces text input