Hotkeys Library
The hotkeys library provides comprehensive keyboard and mouse input manipulation functionality.
Core Functions
hotkeys.create(delay, callback, enabled, loops)
Creates a new hotkey instance with specified parameters.
Parameters
delay
- Time between checks in millisecondscallback
- Function to execute when triggeredenabled
- (Optional) Initial enabled stateloops
- (Optional) Number of times to trigger
Returns
Returns a hotkey object with methods for configuration.
local hk = require("hotkeys")
-- Create a new hotkey
local hotkey = hk.create(
{0x41}, -- define a set of keys, we chose 0x41 for 'A'
function()
print("presssed") -- function that triggers on pressed
end,
function()
print("released") -- function that triggers on released
end
)
hotkeys.check_all()
Checks the state of all registered hotkeys.
Returns
None
Hotkey Methods
:set_pressed(callback)
Sets the callback function for when the hotkey is pressed.
Parameters
callback
- Function to call when the hotkey is pressed
Input Functions
getMousePos()
Returns the current mouse cursor position.
Returns
Table containing x and y coordinates
Constants
MOUSEEVENTF_ABSOLUTE
Specifies absolute mouse movement
MOUSEEVENTF_MOVE
Movement occurred
MOUSEEVENTF_LEFTDOWN
Left button pressed