class GenericHotkey : Object
The GenericHotkey class represents a registered hotkey.
A GenericHotkey calls its assigned Lua function when the configured key combination is pressed.
Inheritance[edit]
| Class
|
Inherits From
|
Description
|
| GenericHotkey
|
Object
|
A hotkey object that executes a Lua callback when its key combination is pressed.
|
Creation[edit]
function createHotkey(function, keys, ...) : GenericHotkey
Creates and initializes a GenericHotkey object.
A maximum of 5 keys can be used for one hotkey.
Function Parameters[edit]
| Parameter
|
Type
|
Description
|
| function
|
Function
|
The Lua function that is called when the hotkey is pressed.
|
| keys
|
Integer
|
The first key in the hotkey combination.
|
| ...
|
Integer (optional)
|
Additional keys in the hotkey combination. A maximum of 5 keys can be used.
|
Alternative Creation Syntax[edit]
function createHotkey(function, {keys, ...}) : GenericHotkey
Creates and initializes a GenericHotkey object using a table of keys.
Function Parameters[edit]
| Parameter
|
Type
|
Description
|
| function
|
Function
|
The Lua function that is called when the hotkey is pressed.
|
| {keys, ...}
|
Table
|
A table containing the key combination. A maximum of 5 keys can be used.
|
Returns[edit]
GenericHotkey — The created and initialized GenericHotkey object.
Properties[edit]
| Property
|
Type
|
Description
|
| DelayBetweenActivate
|
Integer
|
Interval in milliseconds that determines the minimum time between hotkey activations. If 0, the global delay is used.
|
| onHotkey
|
Function
|
The function to call when the hotkey is pressed.
|
Methods[edit]
| Method
|
Return Type
|
Description
|
| getKeys()
|
Table
|
Returns the currently assigned key combination.
|
| setKeys(key, ...)
|
void
|
Sets the hotkey keys. A maximum of 5 keys can be used.
|
| setOnHotkey(table)
|
void
|
Sets the OnHotkey callback handler.
|
| getOnHotkey()
|
Function
|
Returns the current OnHotkey callback handler.
|
Examples[edit]
local hotkey = createHotkey(function()
print("Hotkey pressed")
end, VK_F1)
local hotkey = createHotkey(function()
print("Ctrl + F1 pressed")
end, VK_CONTROL, VK_F1)
hotkey.DelayBetweenActivate = 1000
local hotkey = createHotkey(function()
print("Shift + Alt + F2 pressed")
end, {VK_SHIFT, VK_MENU, VK_F2})
local hotkey = createHotkey(function()
print("Original callback")
end, VK_F3)
hotkey.setOnHotkey(function()
print("Updated callback")
end)
local hotkey = createHotkey(function()
print("F4 pressed")
end, VK_F4)
local key1, key2, key3, key4, key5 = hotkey.getKeys()
print("Key 1: " .. tostring(key1))
print("Key 2: " .. tostring(key2))
print("Key 3: " .. tostring(key3))
print("Key 4: " .. tostring(key4))
print("Key 5: " .. tostring(key5))
local hotkey = createHotkey(function()
print("Ctrl + Alt + F4 pressed")
end, VK_CONTROL, VK_MENU, VK_F4)
local keys = { hotkey.getKeys() }
for i, key in ipairs(keys) do
print(i .. ": " .. tostring(key))
end
local hotkey = createHotkey(function()
print("Old hotkey")
end, VK_F5)
hotkey.setKeys(VK_CONTROL, VK_F5)
Core Lua documentation entry points