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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA listener notified when a key changes state.static interfaceIdentifies a key. -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a callback invoked when a key changes state.voidclean()Clears per-frame state, so that tapped keys are not reported twice.booleanReturns whether a key is currently held down.booleanReturns whether a key went down during the frame just sampled.voidpoll()Samples the keyboard, refreshing what the query methods report.window()Returns the window this input reads from.
-
Method Details
-
window
-
addKeyCallBack
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
Returns whether a key is currently held down.- Parameters:
keyCtx- the key to test- Returns:
truewhile the key is held
-
keyTapped
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:
trueif the key was newly pressed this frame
-