Difference between revisions of "Lua:doKeyPress"
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''' 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: | + | !style="width: 60%;background-color:white;" align="left"|Description |
|- | |- | ||
|Key | |Key | ||
| Line 16: | Line 16: | ||
===Examples=== | ===Examples=== | ||
| − | < | + | <syntaxhighlight lang="lua" line> |
-- Simulate pressing the Enter key | -- Simulate pressing the Enter key | ||
doKeyPress(VK_RETURN) | doKeyPress(VK_RETURN) | ||
| Line 22: | Line 22: | ||
-- Simulate pressing the "A" key | -- Simulate pressing the "A" key | ||
doKeyPress(VK_A) | doKeyPress(VK_A) | ||
| − | </ | + | </syntaxhighlight> |
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| − | |||
| − | + | {{KeyboardMouse}} | |
| − | |||
| − | |||
Latest revision as of 20:17, 25 June 2026
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]
1 -- Simulate pressing the Enter key
2 doKeyPress(VK_RETURN)
3
4 -- Simulate pressing the "A" key
5 doKeyPress(VK_A)