Difference between revisions of "OnKeyDown - ScriptObject"

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search
imported>Kyllagdrgn
imported>Qazaaq
(Replaced input script with DX Scan Code)
Line 6: Line 6:
Minimum required F4SE Version: 0.3.0
Minimum required F4SE Version: 0.3.0


Listens for the pressing of keys whose [[Input_Script#DXScanCodes|DXScanCodes]] have been registered via [[RegisterForKey - ScriptObject|RegisterForKey]]. (This event requires F4SE)
Listens for the pressing of keys whose [[DirectX Scan Codes|Scan Codes]] have been registered via [[RegisterForKey - ScriptObject|RegisterForKey]].


== Syntax ==
== Syntax ==
<source lang="papyrus">Event OnKeyDown(Int KeyCode)
<source lang="papyrus">Event OnKeyDown(int keyCode)</source>
EndEvent</source>


== Parameters ==
== Parameters ==
*KeyCode: The [[Input_Script#DXScanCodes|DXScanCode]] of a key press to listen for.
*KeyCode: The [[DirectX Scan Codes|Scan Code]] of a key press to listen for.


== Examples ==
== Examples ==
<source lang="papyrus">Event OnKeyDown(Int KeyCode)
<source lang="papyrus">
Debug.Trace("A registered key has been pressed")
Event OnKeyDown(int keyCode)
If KeyCode == 160
  Debug.Trace("A registered key has been pressed")
Debug.Trace("L-Shift is registered and has been pressed")
  If (keyCode == 160)
EndIf
      Debug.Trace("L-Shift is registered and has been pressed")
EndEvent</source>
  EndIf
EndEvent
</source>


== Notes ==
== Notes ==
Line 28: Line 29:
== See Also ==
== See Also ==
*[[ScriptObject Script]]
*[[ScriptObject Script]]
*[[Input Script]]
*[[RegisterForKey - ScriptObject]]
*[[RegisterForKey - ScriptObject]]
*[[UnregisterForKey - ScriptObject]]
*[[UnregisterForKey - ScriptObject]]
*[[OnKeyUp - ScriptObject]]
*[[OnKeyUp - ScriptObject]]
*[[DirectX Scan Codes]]

Revision as of 15:02, 6 April 2017

F4SE Member of: ScriptObject Script

Minimum required F4SE Version: 0.3.0

Listens for the pressing of keys whose Scan Codes have been registered via RegisterForKey.

Syntax

Event OnKeyDown(int keyCode)

Parameters

  • KeyCode: The Scan Code of a key press to listen for.

Examples

Event OnKeyDown(int keyCode)
   Debug.Trace("A registered key has been pressed")
   If (keyCode == 160)
      Debug.Trace("L-Shift is registered and has been pressed")
   EndIf
EndEvent

Notes

  • If multiple keys are registered, you'll want to differentiate in the event body as demonstrated above. If only one key will be registered for the form, such differentiation is not necessary.

See Also