-
Notifications
You must be signed in to change notification settings - Fork 0
Input Handling
FroglightInteractive edited this page May 5, 2026
·
2 revisions
NovaEngine provides a simplified wrapper around keyboard state via the NovaInput static class.
NOTE: Mouse input/handling is W.I.P and coming soon
You can check if a key is currently held down, if it was just pressed this frame, or if it was just released this frame.
if (NovaInput.IsKeyPressed(NovaInput.Keys.Space))
{
// Happens every frame the key is held
player.Jump();
}
if (NovaInput.WasKeyJustPressed(NovaInput.Keys.Escape))
{
// Happens only ONCE when the key is first hit
ToggleMenu();
}
if (NovaInput.WasKeyJustReleased(NovaInput.Keys.Space))
{
// Happens only ONCE when the key is first released
player.CutJump();
}NovaInput includes GetAxis. This returns a float, perfect for platformer movement.
protected override void OnUpdate(float dt)
{
// Get direction from A/D keys
float moveDir = NovaInput.GetAxis(NovaInput.Keys.A, NovaInput.Keys.D);
// Apply speed and DeltaTime
player.Velocity.X = moveDir * 300f;
}NovaInput includes GetVector. This returns a normalized Vector2, perfect for top-down movement. It automatically handles the math so diagonal movement isn't faster than cardinal movement.
protected override void OnUpdate(float dt)
{
// Get direction from WASD keys
Vector2 moveDir = NovaInput.GetVector(NovaInput.Keys.A, NovaInput.Keys.D, NovaInput.Keys.W, NovaInput.Keys.S);
// Apply speed and DeltaTime
player.Velocity = moveDir * 300f;
}-
Use
dtwith input: When moving an object based on input, always multiply bydt(Delta Time) in your update loop to ensure consistent speed across different monitors. -
Normalized Vectors: Since
GetVectorreturns a normalized vector (length or 1), you can simply multiply it by aspeedvariable to get your desired velocity. -
Key Enums: NovaEngine uses its own
NovaInput.Keysenum for all key checks.
Documentation
API Reference