Class KeyboardInput

java.lang.Object
technology.sola.engine.input.KeyboardInput

@NullMarked public class KeyboardInput extends Object
KeyboardInput contains information about user interaction with the keyboard.
  • Constructor Details

    • KeyboardInput

      public KeyboardInput()
      Creates a KeyboardInput instance initializing the state of all keys to be released.
  • Method Details

    • isKeyPressed

      public boolean isKeyPressed(int keyCode)
      Checks if a key is pressed based on its keycode.
      Parameters:
      keyCode - the code of the key to check
      Returns:
      true if key is pressed
    • isKeyPressed

      public boolean isKeyPressed(Key key)
      Checks if a Key is pressed.
      Parameters:
      key - the key to check
      Returns:
      true if key is pressed
    • isKeyHeld

      public boolean isKeyHeld(int keyCode)
      Checks if a key is held based on its keycode.
      Parameters:
      keyCode - the code of the key to check
      Returns:
      true if key is held
    • isKeyHeld

      public boolean isKeyHeld(Key key)
      Checks if a Key is held.
      Parameters:
      key - the key to check
      Returns:
      true if key is held
    • updateStatusOfKeys

      public void updateStatusOfKeys()
      Called once per frame to update the current status of the keyboard based on the user's interaction.
    • onKeyPressed

      public void onKeyPressed(KeyEvent keyEvent)
      Called on press of a key.
      Parameters:
      keyEvent - the KeyEvent
    • keyReleased

      public void keyReleased(KeyEvent keyEvent)
      Called on release of a key.
      Parameters:
      keyEvent - the KeyEvent