isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
74 lines • 3.36 kB
TypeScript
import { Keyboard } from "isaac-typescript-definitions";
import { Feature } from "../../private/Feature";
export declare class CustomHotkeys extends Feature {
/**
* The keys are the keyboard keys that trigger the hotkey. The values are the functions that
* contain the arbitrary code to run.
*/
private readonly staticHotkeyFunctionMap;
/**
* The keys are the functions that determine what the hotkey key is. The values are the functions
* that contain the arbitrary code to run.
*/
private readonly dynamicHotkeyFunctionMap;
private readonly keyPressedMap;
private readonly postRender;
private checkIfTriggered;
/**
* Helper function to run arbitrary code when you press and release a specific keyboard key.
*
* This can be used to easily set up custom hotkeys to facilitate custom game features or to
* assist in debugging.
*
* Inputs are checked for in the `POST_RENDER` callback.
*
* This is different from the `setHotkey` function in that the keyboard activation key is not
* hardcoded and is instead the return value of a provided function. This is useful for situations
* where the key can change (like if end-users can specify a custom hotkey using Mod Config Menu).
*
* In order to use this function, you must upgrade your mod with `ISCFeature.CUSTOM_HOTKEYS`.
*
* @param getKeyFunc The function that returns the key that will trigger the hotkey.
* @param triggerFunc A function containing the arbitrary code that you want to execute when the
* hotkey is triggered.
* @public
*/
setConditionalHotkey(getKeyFunc: () => Keyboard | undefined, triggerFunc: () => void): void;
/**
* Helper function to run arbitrary code when you press and release a specific keyboard key.
*
* This can be used to easily set up custom hotkeys to facilitate custom game features or to
* assist in debugging.
*
* Inputs are checked for in the `POST_RENDER` callback.
*
* In order to use this function, you must upgrade your mod with `ISCFeature.CUSTOM_HOTKEYS`.
*
* @param keyboard The key that you want to trigger the hotkey.
* @param triggerFunc A function containing the arbitrary code that you want to execute when the
* hotkey is triggered.
* @public
*/
setHotkey(keyboard: Keyboard, triggerFunc: () => void): void;
/**
* Helper function to remove a hotkey created with the `setConditionalHotkey` function.
*
* In order to use this function, you must upgrade your mod with `ISCFeature.CUSTOM_HOTKEYS`.
*
* @param getKeyFunc Equal to the `getKeyFunc` that you passed when initially registering the
* hotkey.
* @public
*/
unsetConditionalHotkey(getKeyFunc: () => Keyboard | undefined): void;
/**
* Helper function to remove a hotkey created with the `setHotkey` function.
*
* In order to use this function, you must upgrade your mod with `ISCFeature.CUSTOM_HOTKEYS`.
*
* @param keyboard Equal to the keyboard value that you passed when initially registering the
* hotkey.
* @public
*/
unsetHotkey(keyboard: Keyboard): void;
}
//# sourceMappingURL=CustomHotkeys.d.ts.map