Difference between revisions of "Lua:isKeyPressed"

From Cheat Engine
Jump to navigation Jump to search
m
m (Added CodeBox Template.)
 
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' isKeyPressed(''Key'') ''':''' Boolean
+
{{CodeBox|'''function''' isKeyPressed(''Key'') ''':''' Boolean}}
  
 
Returns true if the specified key is currently pressed.
 
Returns true if the specified key is currently pressed.
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 29: Line 29:
 
</pre>
 
</pre>
  
== See also ==
+
{{LuaSeeAlso}}
* [[keyDown]]
+
 
* [[keyUp]]
+
{{KeyboardMouse}}
* [[doKeyPress]]
 
* [[Virtual-Key Code]]
 

Latest revision as of 23:55, 4 December 2025

<> Function

function isKeyPressed(Key) : Boolean

Returns true if the specified key is currently pressed.

Function Parameters[edit]

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

Returns[edit]

Boolean — true if the key is pressed, false otherwise.

Examples[edit]

if isKeyPressed(VK_SPACE) then
  print("Spacebar is currently pressed!")
end

if isKeyPressed(VK_LSHIFT) then
  print("Left Shift is pressed")
end

See also[edit]

Lua
Script Engine

Related Functions[edit]

getMousePos
setMousePos
isKeyPressed
keyDown
keyUp
doKeyPress
mouse_event
setGlobalKeyPollInterval
setGlobalDelayBetweenHotkeyActivation