Difference between revisions of "Lua:doKeyPress"

From Cheat Engine
Jump to navigation Jump to search
m
m (Added CodeBox Template.)
 
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' doKeyPress(''Key'')
+
{{CodeBox|'''function''' doKeyPress(''Key'')}}
  
 
Simulates a key press by sending a key down followed by a key up event for the specified key.
 
Simulates a key press by sending a key down followed by a key up event for the specified key.
Line 8: Line 8:
 
!align="left"|Parameter
 
!align="left"|Parameter
 
!align="left"|Type
 
!align="left"|Type
!style="width: 80%;background-color:white;" align="left"|Description
+
!style="width: 60%;background-color:white;" align="left"|Description
 
|-
 
|-
 
|Key
 
|Key
Line 25: Line 25:
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}
* [[Virtual-Key Code]]
 
  
=== Related Functions ===
+
{{KeyboardMouse}}
* [[Lua:keyUp|keyUp]]
 
* [[Lua:keyDown|keyDown]]
 

Latest revision as of 23:57, 4 December 2025

<> Function

function doKeyPress(Key)

Simulates a key press by sending a key down followed by a key up event for the specified key.

Function Parameters[edit]

Parameter Type Description
Key Integer or Virtual-Key Code The virtual key code of the key to press (e.g., VK_F1, VK_SHIFT).

Examples[edit]

-- Simulate pressing the Enter key
doKeyPress(VK_RETURN)

-- Simulate pressing the "A" key
doKeyPress(VK_A)

See also[edit]

Lua
Script Engine

Related Functions[edit]

getMousePos
setMousePos
isKeyPressed
keyDown
keyUp
doKeyPress
mouse_event
setGlobalKeyPollInterval
setGlobalDelayBetweenHotkeyActivation