Interface RenderModuleKeyboardInput

All Known Implementing Classes:
GLFWRenderModuleKeyboardInput

public interface RenderModuleKeyboardInput
Keyboard state for one window, independent of the windowing library providing it.

State is sampled rather than delivered: poll() captures the keyboard once per frame, and the query methods answer against that snapshot, so every caller within a frame sees the same input regardless of when it asks.

  • Method Details

    • window

      Returns the window this input reads from.
      Returns:
      the owning window
    • addKeyCallBack

      void addKeyCallBack(RenderModuleKeyboardInput.KeyCallback callback)
      Registers a callback invoked when a key changes state.
      Parameters:
      callback - the callback to invoke
    • poll

      void poll()
      Samples the keyboard, refreshing what the query methods report.

      Called once per frame by the owning window.

    • clean

      void clean()
      Clears per-frame state, so that tapped keys are not reported twice.
    • keyPressed

      boolean keyPressed(RenderModuleKeyboardInput.KeyCtx keyCtx)
      Returns whether a key is currently held down.
      Parameters:
      keyCtx - the key to test
      Returns:
      true while the key is held
    • keyTapped

      boolean keyTapped(RenderModuleKeyboardInput.KeyCtx keyCtx)
      Returns whether a key went down during the frame just sampled.

      Unlike keyPressed(RenderModuleKeyboardInput.KeyCtx), this is true for a single frame per press.

      Parameters:
      keyCtx - the key to test
      Returns:
      true if the key was newly pressed this frame