Background for Skyrim SE
Member of the Form script
voidfunctionRegisterForKey(intkeyCode)Native

Description

Wiki Description

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

Documentation Comment

Registers for OnKeyDown and OnKeyUp events for the given keycode.


Caveats

CK Wiki - Notes

  • Use of the input events is much less resource consumptive than polling for Input.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 Input.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 Input 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

Parameters

intkeyCode

CK Wiki Description

The Input of the key to listen for.


Examples

RegisterForKey(42) ; L-Shift

Auto-Generated Example

int myInt__keyCode

myForm__toCallFunctionOn.RegisterForKey(myInt__keyCode)

Related Pages


Additional References

View this function’s page on the Skyrim Creation Kit Wiki

Some data provided by the Skyrim Creation Kit Wiki. Licensed under the Creative Commons Attribution-ShareAlike license.