IsKeyPressed - Input: Difference between revisions
Jump to navigation
Jump to search
m
→Examples: Formatting
imported>JustinOther (Examples/Notes) |
imported>JustinOther m (→Examples: Formatting) |
||
| Line 36: | Line 36: | ||
EndIf | EndIf | ||
RegisterForSingleUpdate(0.25) | RegisterForSingleUpdate(0.25) | ||
EndEvent</source>*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. | EndEvent</source> | ||
*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 != IsKeyPressed(iHotkey) | ||
| Line 46: | Line 47: | ||
RegisterForSingleUpdate(0.25) | RegisterForSingleUpdate(0.25) | ||
EndEvent</source> | EndEvent</source> | ||
== Notes == | == Notes == | ||
*To avoid multithreading mishaps, it's generally best to use [[RegisterForSingleUpdate - Form|RegisterForSingleUpdate]] rather than [[RegisterForUpdate - Form|RegisterForUpdate]]. | *To avoid multithreading mishaps, it's generally best to use [[RegisterForSingleUpdate - Form|RegisterForSingleUpdate]] rather than [[RegisterForUpdate - Form|RegisterForUpdate]]. | ||