Difference between revisions of "Lua:keyDown"

From Cheat Engine
Jump to navigation Jump to search
m
m (Syntax Highlighting.)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' keyDown(''Key'')
+
{{CodeBox|'''function''' keyDown(''Key'')}}
  
 
Causes the specified key to go into the "down" (pressed) state.   
 
Causes the specified key to go into the "down" (pressed) state.   
Line 9: Line 9:
 
!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 17: Line 17:
  
 
===Examples===
 
===Examples===
<pre>
+
<syntaxhighlight lang="lua" line>
 
-- Simulate pressing and holding the left control key
 
-- Simulate pressing and holding the left control key
 
keyDown(VK_LCONTROL)
 
keyDown(VK_LCONTROL)
Line 23: Line 23:
 
-- Simulate pressing and holding the "A" key
 
-- Simulate pressing and holding the "A" key
 
keyDown(VK_A)
 
keyDown(VK_A)
</pre>
+
</syntaxhighlight>
  
== See also ==
+
{{LuaSeeAlso}}
* [[keyUp]]
+
 
* [[doKeyPress]]
+
{{KeyboardMouse}}
* [[isKeyPressed]]
 
* [[Virtual-Key Code]]
 

Latest revision as of 20:16, 25 June 2026

<> Lua API Reference

function keyDown(Key)

Causes the specified key to go into the "down" (pressed) state. This simulates pressing and holding the key.

Function Parameters[edit]

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

Examples[edit]

1 -- Simulate pressing and holding the left control key
2 keyDown(VK_LCONTROL)
3 
4 -- Simulate pressing and holding the "A" key
5 keyDown(VK_A)

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Mouse Related Functions

Keyboard Related Functions

Global Hotkey Related Functions