RegisterForKey - Form

From Creation Kit
Jump to: navigation, search

SKSE Member of: Form Script

Minimum required SKSE Version: 1.06.00

Registers the given DXScanCode for OnKeyDown and OnKeyUp events. (This function requires SKSE)

Syntax

Function RegisterForKey(Int KeyCode) Native

Parameters

Return Value

NONE

Examples

RegisterForKey(42) ; L-Shift

Notes

  • Use of the input events is much less resource consumptive than polling for IsKeyPressed in an OnUpdate event. Whenever possible, use the events preferentially.
  • Avoid using keys already claimed by Skyrim. Invariably, mod added hotkeys will conflict, so it's best to offer a way to rebind your hotkey(s) via GetNthKeyPressed from an Options Menu or other readily accessible means such as a scripted inventory item. This will afford your mod elasticity and allow it to work in tandem with other hotkey bearing mods.
  • Using a property to store the DXScanCode of the key you are listening for will allow the same script to be easily reused to listen for different keys simultaneously, as this allows the property to be set (or the default value overridden) in the Creation Kit without editing the script's source

See Also