Package codedraw

Class KeyPressEvent

java.lang.Object
codedraw.Event
codedraw.KeyPressEvent

public class KeyPressEvent extends Event
This argument is given continuously while a key is being held down.
  • Method Details

    • getKey

      public Key getKey()
      Gets the key that was pressed to trigger the event. If the key is not found or unknown the key value Key.UNDEFINED will be used.
      Returns:
      a key.
    • getChar

      public char getChar()
      Gets the character representation of the key that was pressed. For example pressing the A key + SHIFT will result in an 'A', but without pressing SHIFT will result in a lowercase 'a'.
      Returns:
      a char.
    • getExtendedKeyCode

      public int getExtendedKeyCode()
      Returns the key code of the key pressed. The extended key code can be used to uniquely identify a key on a keyboard.
      Returns:
      the key code.
    • isControlDown

      public boolean isControlDown()
      Gets whether control was pressed.
      Returns:
      true if control was pressed, otherwise false.
    • isAltDown

      public boolean isAltDown()
      Gets whether alt was pressed.
      Returns:
      true if alt was pressed, otherwise false.
    • isAltGraphDown

      public boolean isAltGraphDown()
      Gets whether alt graph was pressed.
      Returns:
      true if alt graph was pressed, otherwise false.
    • isShiftDown

      public boolean isShiftDown()
      Gets whether shift was pressed.
      Returns:
      true if shift was pressed, otherwise false.
    • toString

      public String toString()
      Overrides:
      toString in class Object