Difference between revisions of "Lua:keyDown"

From Cheat Engine
Jump to navigation Jump to search
m
 
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' keyDown(''key'')
+
'''function''' keyDown(''Key'')
  
Sets the key to the down state. Toggling between down and up can be used to type strings. And holding down can also be used to drag stuff. (Like the left mouse button down)
+
Causes the specified key to go into the "down" (pressed) state.
 +
This simulates pressing and holding the key.
  
 
===Function Parameters===
 
===Function Parameters===
{|width="85%" cellpadding="10%" cellpadding="5%" cellspacing="0" border="0"
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 
!align="left"|Parameter
 
!align="left"|Parameter
 
!align="left"|Type
 
!align="left"|Type
 
!style="width: 80%;background-color:white;" align="left"|Description
 
!style="width: 80%;background-color:white;" align="left"|Description
 
|-
 
|-
|key
+
|Key
|[[Virtual-Key Code]]
+
|Integer or [[Virtual-Key Code]]
|The keycode for the key to set down
+
|The virtual key code of the key to press down (e.g., <code>VK_F1</code>, <code>VK_SHIFT</code>).
 
|}
 
|}
  
 +
===Examples===
 +
<pre>
 +
-- Simulate pressing and holding the left control key
 +
keyDown(VK_LCONTROL)
  
{{LuaSeeAlso}}
+
-- Simulate pressing and holding the "A" key
 +
keyDown(VK_A)
 +
</pre>
 +
 
 +
== See also ==
 +
* [[keyUp]]
 +
* [[doKeyPress]]
 +
* [[isKeyPressed]]
 
* [[Virtual-Key Code]]
 
* [[Virtual-Key Code]]
 
=== Related Functions ===
 
* [[Lua:keyUp|keyUp]]
 

Latest revision as of 18:00, 11 July 2025

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]

-- Simulate pressing and holding the left control key
keyDown(VK_LCONTROL)

-- Simulate pressing and holding the "A" key
keyDown(VK_A)

See also[edit]