Difference between revisions of "Lua:keyDown"
Jump to navigation
Jump to search
(Created page with ''''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 …') |
m (Syntax Highlighting.) |
||
| (6 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | '''function''' keyDown('' | + | [[Category:Lua]] |
| + | {{CodeBox|'''function''' keyDown(''Key'')}} | ||
| − | + | 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 | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" |
!align="left"|Parameter | !align="left"|Parameter | ||
!align="left"|Type | !align="left"|Type | ||
| − | !style="width: | + | !style="width: 60%;background-color:white;" align="left"|Description |
|- | |- | ||
| − | | | + | |Key |
| − | |[[Virtual-Key Code]] | + | |Integer or [[Virtual-Key Code]] |
| − | |The | + | |The virtual key code of the key to press down (e.g., <code>VK_F1</code>, <code>VK_SHIFT</code>). |
|} | |} | ||
| + | ===Examples=== | ||
| + | <syntaxhighlight lang="lua" line> | ||
| + | -- Simulate pressing and holding the left control key | ||
| + | keyDown(VK_LCONTROL) | ||
| − | + | -- Simulate pressing and holding the "A" key | |
| − | + | keyDown(VK_A) | |
| − | + | </syntaxhighlight> | |
| − | + | ||
| + | {{LuaSeeAlso}} | ||
| + | |||
| + | {{KeyboardMouse}} | ||
Latest revision as of 20:16, 25 June 2026
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)