Class TimbnInput
Tells a mod's hotkeys when the game would take the same key press itself, so a mod key does not fire behind an
open window or in the middle of a cutscene. Use it in place of checking IsInGame and
LazyWindowsStackController.ActiveWindow by hand.
public static class TimbnInput
- Inheritance
-
TimbnInput
- Inherited Members
Properties
GameHasInteraction
True when the game has its own interaction ready for the Interaction key, such as a world object in reach or a big drop to pick up. A mod that also uses the Interaction key should stay out of the way then.
public static bool GameHasInteraction { get; }
Property Value
HotkeysEnabled
True when a save is loaded, no game window (inventory, crafting, pause menu, a text field) is open, and the game is reading input. It does not look at whether the player can move, so it suits a key that must still work while a mod holds the player still, such as the key that ends campfire meditation.
public static bool HotkeysEnabled { get; }
Property Value
PlayerHasControl
True when HotkeysEnabled is and the player can also move and act. The game takes control away
during dialog, cutscenes, sleep, teleports, fishing, building, ladders, work at a station, and attacks, and
its own input code checks PlayerController.IsControlsEnabled the same way. Use it for a hotkey that
acts on the world, such as spawning an item at the player.
public static bool PlayerHasControl { get; }
Property Value
Methods
IsDownIgnoringOtherKeys(KeyboardShortcut)
Whether shortcut was pressed this frame, even while other keys are held. BepInEx's own
IsDown says no whenever any key beyond the shortcut is down, so a key that has to work while the player walks,
such as a jump, reads it with this instead. It does not check whether the game is reading input, so pair it
with HotkeysEnabled or PlayerHasControl as the key needs.
public static bool IsDownIgnoringOtherKeys(this KeyboardShortcut shortcut)
Parameters
shortcutKeyboardShortcut
Returns
Examples
if (TimbnInput.PlayerHasControl && PluginConfig.Jump.Value.IsDownIgnoringOtherKeys())
jump.Start();
IsDownInGame(KeyboardShortcut)
Whether shortcut was pressed this frame while HotkeysEnabled holds. Call it
from OnUpdate in place of IsDown().
public static bool IsDownInGame(this KeyboardShortcut shortcut)
Parameters
shortcutKeyboardShortcut
Returns
Examples
if (PluginConfig.QuickStack.Value.IsDownInGame())
QuickStack.IntoNearbyChests(PluginConfig.QuickStackRadius.Value);
IsDownInGame(GameKey)
Whether one of the game's own keys, such as Interaction, was pressed this frame while HotkeysEnabled holds. It reads the key however the player has bound it, on a keyboard or a gamepad. Pair it with a TimbnInteractionHint showing that key, so the game leaves the press to the mod.
public static bool IsDownInGame(this GameKey key)
Parameters
keyGameKeyThe game's key, such as GameKey.Interaction.
Returns
Examples
_hint.Show(fire, LLBase.L("my_mod_meditate"));
if (GameKey.Interaction.IsDownInGame())
SitDown();
IsDownInWindow<TWindow>(KeyboardShortcut)
Whether shortcut was pressed this frame while a game window of the given type is open and
on top, for a key that adds to one of the game's own windows.
public static bool IsDownInWindow<TWindow>(this KeyboardShortcut shortcut) where TWindow : LazyWidgetBase
Parameters
shortcutKeyboardShortcut
Returns
Type Parameters
TWindowThe window's type.
Examples
if (PluginConfig.TogglePin.Value.IsDownInWindow<UIBuildingWindow>())
buildPins.TogglePinOnHovered();
IsDownWithControl(KeyboardShortcut)
Whether shortcut was pressed this frame while PlayerHasControl holds, so the
key does nothing during dialog, cutscenes, or any other time the player cannot act.
public static bool IsDownWithControl(this KeyboardShortcut shortcut)
Parameters
shortcutKeyboardShortcut
Returns
IsHeldIgnoringOtherKeys(KeyboardShortcut)
Whether shortcut is held right now, even while other keys are held, like IsDownIgnoringOtherKeys(KeyboardShortcut) for a held key.
public static bool IsHeldIgnoringOtherKeys(this KeyboardShortcut shortcut)
Parameters
shortcutKeyboardShortcut
Returns
IsHeldInGame(GameKey)
Whether one of the game's own keys is held right now while HotkeysEnabled holds, like IsDownInGame(GameKey) for a held key.
public static bool IsHeldInGame(this GameKey key)
Parameters
keyGameKeyThe game's key, such as GameKey.Action.