IsKeyPressed - Input: Difference between revisions

Jump to navigation Jump to search
m
Oops. Input hadn't been imported.
imported>JustinOther
m (Added required SKSE version)
imported>JustinOther
m (Oops. Input hadn't been imported.)
Line 29: Line 29:


Event OnUpdate()
Event OnUpdate()
If bIsHotkeyPressed != IsKeyPressed(iHotkey) ; Only run code when the status changes
If bIsHotkeyPressed != Input.IsKeyPressed(iHotkey) ; Only run code when the status changes
bIsHotkeyPressed = !bIsHotkeyPressed ; Set bool to whatever it isn't
bIsHotkeyPressed = !bIsHotkeyPressed ; Set bool to whatever it isn't
If bIsHotkeyPressed ; == True
If bIsHotkeyPressed ; == True
Line 41: Line 41:
*Do something exactly once each time a key is pressed. We'll take the scaffolding from above as rendered given the difference is exclusively in the OnUpdate event. Without the primary check and consecutive bool-flip, [[Trace - Debug|Trace]] would be called every iteration.
*Do something exactly once each time a key is pressed. We'll take the scaffolding from above as rendered given the difference is exclusively in the OnUpdate event. Without the primary check and consecutive bool-flip, [[Trace - Debug|Trace]] would be called every iteration.
<source lang="papyrus">Event OnUpdate()
<source lang="papyrus">Event OnUpdate()
If bIsHotkeyPressed != IsKeyPressed(iHotkey)
If bIsHotkeyPressed != Input.IsKeyPressed(iHotkey)
bIsHotkeyPressed = !bIsHotkeyPressed
bIsHotkeyPressed = !bIsHotkeyPressed
If bIsHotkeyPressed
If bIsHotkeyPressed
Anonymous user

Navigation menu