IsKeyPressed - Input: Difference between revisions

Jump to navigation Jump to search
Changed iHotkey to a property and added note about how it enables ease of reuse
imported>JustinOther
m (→‎Examples: Formatting)
imported>Cipscis
(Changed iHotkey to a property and added note about how it enables ease of reuse)
Line 20: Line 20:
*Do/Undo something when a key is pressed/released. [[States (Papyrus)|States]] ''could'' be used in lieu of the boolean guard, but would verifiably not save any resources in this context.
*Do/Undo something when a key is pressed/released. [[States (Papyrus)|States]] ''could'' be used in lieu of the boolean guard, but would verifiably not save any resources in this context.
<source lang="papyrus">Bool bIsHotkeyPressed ; = False
<source lang="papyrus">Bool bIsHotkeyPressed ; = False
Int iHotkey = 184 ; R-Alt
Int Property iHotkey = 184 Auto ; R-Alt by default


Event OnInit()
Event OnInit()
Line 53: Line 53:
*When the [[Input_Script#Events|Input Events]] arrive, they'll be preferable to the above polling methods as their 'cost' will be less.
*When the [[Input_Script#Events|Input Events]] arrive, they'll be preferable to the above polling methods as their 'cost' will be less.
*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 - 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.
*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 - 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 dxKeycode of the key you are polling will allow the same script to be easily reused to poll for different keys simultaneously, as this allows the dxKeycode to be set (or the default value overridden) in the Creation Kit without editing the script's source
== See Also ==
== See Also ==
*[[Input Script]]
*[[Input Script]]
*[[GetNumKeysPressed - Input]]
*[[GetNumKeysPressed - Input]]
*[[GetNthKeyPressed - Input]]
*[[GetNthKeyPressed - Input]]
Anonymous user

Navigation menu