Class Keyboard

java.lang.Object
swingtree.input.Keyboard

public class Keyboard extends Object
This is a simple Singleton class representing the current state of the keyboard. It is not a keyboard shortcut implementation but merely a fast API to check if a certain key on the keyboard has been pressed... The keyboard class can not be used to hook up lambda callbacks, but merely ought to serve as a common way to query the current state of the keyboard!
  • Constructor Details

    • Keyboard

      public Keyboard()
  • Method Details

    • get

      public static Keyboard get()
      Exposes the singleton instance of the Keyboard class.
      Returns:
      The singleton instance of the Keyboard class.
    • isPressed

      public boolean isPressed(Keyboard.Key key)
      This method checks if the supplied Keyboard.Key is currently pressed on the keyboard.
      Parameters:
      key - An instance of the Keyboard.Key enum representing a keyboard key.
      Returns:
      The truth value determining if the specified Keyboard.Key type is currently pressed by the user.
      Throws:
      NullPointerException - If the supplied Keyboard.Key is null, use Keyboard.Key.NONE instead to check if no key is currently pressed.