reckfellENGINE

Keys, mouse and rebinding

Distinguish physical keys from symbols, preserve gamepad bindings and capture the mouse correctly.

On this page

Actions instead of keys

Define Input Map actions for movement and game commands so keyboard and gamepad use the same code. For text entry, use LineEdit or TextEdit rather than a list of gameplay actions.

InputEventKey fieldUse
PhysicalKeycodePhysical key position, such as the usual WASD arrangement regardless of keyboard layout
KeycodeLatin key label in the current layout, such as S for Ctrl + S
KeyLabelLocalized key label for player prompts
UnicodeEntered character; this alone is not a full text field with IME support

Rebind only the keyboard

This class does not attach to an entity. Save it as KeyboardBindings.cs. KeyboardBindings.SetPhysicalKey("interact", Key.F) replaces keyboard bindings for an existing action while preserving mouse and gamepad bindings:

C#
using Reckfell;

public static class KeyboardBindings
{
    public static Error SetPhysicalKey(string action, Key key)
    {
        if (!InputMap.HasAction(action))
            return Error.DoesNotExist;

        foreach (InputEvent binding in InputMap.ActionGetEvents(action))
        {
            if (binding is InputEventKey)
                InputMap.ActionEraseEvent(action, binding);
        }

        InputMap.ActionAddEvent(action, new InputEventKey { PhysicalKeycode = key });
        return Error.Ok;
    }
}

Check the result: an unknown action returns Error.DoesNotExist. Rebind after finishing event capture so the new key does not trigger a game command from that same event. Disable gameplay controls while the binding screen is open; provide cancellation and restore defaults.

Runtime Input Map changes are not automatically saved to project.reckfell. Write chosen bindings to user:// and restore them at startup. Store the action name, event kind, key code and modifiers if your UI supports them. See saving data.

Camera and mouse

For first-person look, set Input.MouseMode = Input.MouseModeEnum.Captured. Read InputEventMouseMotion.ScreenRelative for screen-space motion; Relative depends on window content scaling. This is already an event displacement, so do not multiply it by delta as if it were a speed.

When opening a menu, return to Input.MouseModeEnum.Visible and disable camera rotation. Capture again deliberately when closing it. Test loss of window focus and exiting capture separately.

Gamepad

Bind positive and negative stick directions to actions and read them with GetVector(). Tune the dead zone on a real device: too small causes drift; too large reduces precision. Handle controller disconnection and avoid assuming a single permanent device index.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.