Package input

Class Keyboard

java.lang.Object
input.Keyboard

public class Keyboard extends Object
  • Field Details

    • SPACE

      public static int SPACE
    • W_KEY

      public static int W_KEY
    • A_KEY

      public static int A_KEY
    • S_KEY

      public static int S_KEY
    • D_KEY

      public static int D_KEY
    • UP_ARROW

      public static int UP_ARROW
    • LEFT_ARROW

      public static int LEFT_ARROW
    • DOWN_ARROW

      public static int DOWN_ARROW
    • RIGHT_ARROW

      public static int RIGHT_ARROW
    • keystateBitfields

      public static byte[] keystateBitfields
      A bitfield array to store button states. First bit is key down Second bit is key up Third bit is key held
  • Constructor Details

    • Keyboard

      public Keyboard()
  • Method Details

    • setupCallbacks

      public static void setupCallbacks()
      Subscribes to key event
    • getKey

      public static boolean getKey(int keycode)
      Parameters:
      keycode - keycode representing the key to be checked
      Returns:
      Returns true if the key is currently pressed or held, otherwise returns false
    • getKeyDown

      public static boolean getKeyDown(int keycode)
      Returns true if a key is was just pressed, then returns false until the key is released and pressed again.
      Parameters:
      keycode - key-code representing the key to be checked.
      Returns:
      Returns true if the key was just pressed, otherwise returns false.
    • keyDownOrHold

      public static boolean keyDownOrHold(int keycode)
    • getKeyUp

      public static boolean getKeyUp(int keycode)
      Returns true if a key was just released.
      Parameters:
      keycode - key-code representing the key to be checked.
      Returns:
      Returns true if the key was just released, otherwise returns false.
    • getKeyHeld

      public static boolean getKeyHeld(int keycode)
      Returns true if a key was held.
      Parameters:
      keycode - key-code representing the key to be checked.
      Returns:
      Returns true if the key was held, otherwise returns false.