Keybind Lib is an API for Undermine modders to easily add keybinds to their mods.
Report issues here on the GitHub Issues page, or if it's urgent, join my Discord and contact me directly.
KeybindLib is released under the Apache License, Version 2.0.
- Install the BepInEx pack for Undermine
- Download and extract the zip.
- Copy the .dll file to
<Undermine-Steam-Files>/BepInEx/pluginsdirectory. - Run the game. Enjoy!
- Visual Studio: right-click on
Dependenciesin your project, click onAdd Project Reference..., thenBrowse..., select the dll, and clickOK. The XML will be detected automatically if it's in the same location as the dll. - JetBrains Rider: right-click on
Dependenciesin your project, click onReference, thenAdd From..., select the dll, and clickAdd. The XML will be detected automatically if it's in the same location as the dll.
It is highly recommended that you also download KeybindLib.xml with the KeybindLib.dll and put them in the same directory. This will let you reference KeybindLib and view its documentation in your IDE with more in-depth information on how to use functions.
This is example will show you how to create a keybind listener.
- In this case, the mod's ID is
"TestDeveloper.TestMod"and the key's ID is"test_key". - It has the displayName value of
"Test Keybind"which is displayed in the Custom Mod Keybinds input page. - It has the defaultKey value of
KeyCode.F, which will, if an existing key assignment for that id ("test_key"in this case) isn't found, will be set to this default value. - It has the keyEnvironment value of
KeybindManager.KeyEnvironment.Anyso, the keybind will be active ingame, on the title screen, etc. - It has the keyPressType value of
KeybindManager.KeyPressType.OnKeyDownso, keybind will only run once instantly on key press.
using UnityEngine;
using HarmonyLib;
KeybindManager.KeyDetails testKeydetails = new KeybindManager.KeyDetails(
KeyCode.F,
KeybindManager.KeyEnvironment.Any,
KeybindManager.KeyPressType.OnKeyDown,
"Test Keybind",
"Test Category"
);
KeybindManager.RegisterEvent("TestDeveloper.TestMod", "test_key", testKeydetails).AddListener(() =>
{
KeyCode currentKey = KeybindManager.GetKey("TestDeveloper.TestMod", "test_key");
Debug.Log($"{currentKey} was pressed!");
});
-
Clone this GitHub repository.
-
Copy files from
<Undermine-Steam-Files>/BepInEx/coreto.libs0Harmony.dllBepInEx.dllBepInEx.Harmony.dll
-
Copy files from
<Undermine-Steam-Files>/UnderMine_Data/Managedto.libsRewired_Core.dllUndermine.dllUnity.TextMeshPro.dllUnityEngine.dllUnityEngine.CoreModule.dllUnityEngine.UI.dll
-
Build solution
-
Built .dll and .xml should be located in
bin/Debug/KeybindLib.dll