mcNows
Nows Loader 0.9.1 / Minecraft 26.2

Client Keybinds

Register and poll Minecraft keybinds through the mc adapter client/keybind package.

Some APIs may still change or behave unevenly because they do not have enough real-world use cases and test coverage yet.

Client Keybinds

The keybind API lives in space.nows.mc.api.client.keybind. Use it for controls that should appear in Minecraft’s Controls screen without hand-writing each version’s key mapping registration.

Register A Category

Categories should be translation keys. Register a sort order if your category should sit near related controls.

KeybindApi keys = MinecraftApi.keybinds(context);

keys.registerCategory("key.categories.my_mod", 50);

If you skip the category overload, Nows uses KeybindApi.DEFAULT_CATEGORY.

Register A Press Action

Use the callback overload for one-shot actions such as opening a screen.

keys.registerKeyboard(
        "key.my_mod.open_machine",
        "key.categories.my_mod",
        GLFW.GLFW_KEY_M,
        () -> MyScreens.openMachine(context));

The id should also be a translation key. Minecraft will localize it in the Controls screen.

Poll A Held Key

Use the returned KeybindRegistration when the action should continue while the key is held.

KeybindRegistration boost = keys.registerKeyboard(
        "key.my_mod.boost",
        "key.categories.my_mod",
        GLFW.GLFW_KEY_B);

MinecraftApi.events(context).clientTick(client -> {
    if (boost.isDown() && client.player != null) {
        client.player.setDeltaMovement(
                client.player.getDeltaMovement().multiply(1.2D, 1.0D, 1.2D));
    }
});

Polling belongs in client tick code. Avoid doing repeated work inside a press callback.

Attach A Listener Later

Use onPress when the keybind is registered elsewhere and you only want to add behavior.

keys.onPress("key.my_mod.open_machine", () -> LOGGER.debug("Machine key pressed"));

Use keybind(id) and keybinds() for diagnostics or mod screens that need to show current registrations.