What are you searching for?

Modern KeyBinding

Modern KeyBinding

Port KeyModifier && KeyConflictContext back to Fabric & Early Forge

download 465.4K Downloads · favorite 121 Followers · Updated 2 years ago
Cursed Fabric Forge Library Utility 1.7.10 1.8.9 1.16.5 1.18.2 1.19.2 +4 more

Versions

inventory_2
Fabric-1.20.4-1.3.0

1.20.4-1.3.0 · 2 years ago · 52.44 KB

Release download
Fabric 1.20.4
inventory_2
Fabric-1.20.X-1.2.0

1.20.X-1.2.0 · 2 years ago · 56.54 KB

Release download
Fabric 1.20 1.20.1
inventory_2
Fabric-1.20-1.1.0

1.20-1.1.0 · 2 years ago · 54.70 KB

Release download
Fabric 1.20
inventory_2
Fabric-1.19.4-1.1.0

1.19.4-1.1.0 · 2 years ago · 54.73 KB

Release download
Fabric 1.19.4
inventory_2
Fabric-1.19.2-1.1.0

1.19.2-1.1.0 · 2 years ago · 55.27 KB

Release download
Fabric 1.19.2

About

Modern KeyBinding

The mod ported the newer version's KeyModifier && KeyConflictContext back to Fabric & Early Forge.

Features

You can now define a keybinding's activation key with key modifiers. Like "Ctrl + G" or "Alt + S";

The keybindings with the same activation key but different key conflict contexts no longer conflict.

"Non-conflict keys" (disabled by default): The keybindings with the same key will all be activated if the key is pressed.

Attention:

The mod will crash with NEI. Use NEI Unofficial(Dependencies: CodeChickenCore | CodeChickenLib) by GTNH instead.

Import as a Gradle dependency

repositories {
    //...
    maven {
        url "https://maven.nova-committee.cn/releases"
    }
}
dependencies {
    //...
    // Forge
    implementation "committee.nova.mkb.forge:mkb-${mc_version}:${mod_version}"
    // Fabric
    modImplementation "committee.nova.mkb.fabric:mkb-${mc_version}:${mod_version}"
}

Register a keybinding

Register a keybinding that:

  • Activates when Alt and C are pressed;

  • Only available in GUI.

ClientProxy.java

public class ClientProxy {
    public void init(final FMLInitializationEvent event) {
        //...
        yourKeyBinding = KeyBindingRegistry.INSTANCE.registerKeyBinding("key.exampleKey", KeyConflictContext.GUI, KeyModifier.ALT, Keyboard.KEY_C, "key.categories.example");
    }
}

Change the properties of an existing keybinding

ClientProxy.java

public class ClientProxy {
    //...
    public void postInit(final FMLPostInitializationEvent event) {
        final IKeyBinding extended = (IKeyBinding) yourKeyBinding;
        // Change the key's keyCode and modifier, as their default values.
        extended.setInitialKeyModifierAndCode(KeyModifier.ALT, Keyboard.KEY_E);
        // Change the key's keyCode and modifier.
        extended.setKeyModifierAndCode(KeyModifier.ALT, Keyboard.KEY_E);
        // Change the key's conflict context.
        extended.setKeyConflictContext(KeyConflictContext.IN_GAME);
    }
}
open_in_new View on Modrinth
Compatibility
Client: Required Server: Unsupported
gavel LicenseRef-All-Rights-Reserved

Conversation

What are your thoughts?

Related projects

Library
Fabric API
Fabric API

by modmuss50

Lightweight and modular API providing common hooks and intercompatibility measures utilized by mods using the Fabric toolchain.

download 128.4M
favorite 27,401
Library
Cloth Config API
Cloth Config API

by shedaniel

Configuration Library for Minecraft Mods

download 94.4M
favorite 13,670
Optimization Utility
FerriteCore
FerriteCore

by malte0811

Memory usage optimizations

download 84.3M
favorite 12,712
Utility
Mod Menu
Mod Menu

by Prospector

Adds a mod menu to view the list of mods you have installed.

download 77.7M
favorite 22,127
lock Cookie consent

SkinMC uses cookies to provide functionality and features.