pinnacle/api/lua/input.lua

33 lines
838 B
Lua
Raw Normal View History

2023-08-01 18:06:35 +02:00
-- SPDX-License-Identifier: GPL-3.0-or-later
2023-06-26 00:18:50 +02:00
2023-07-22 04:02:02 +02:00
---@class InputModule
local input_module = {
keys = require("keys"),
}
2023-06-15 19:42:34 +02:00
---Set a keybind. If called with an already existing keybind, it gets replaced.
2023-07-11 18:59:38 +02:00
---
2023-07-18 22:12:23 +02:00
---### Example
2023-07-11 18:59:38 +02:00
---
---```lua
2023-07-22 04:02:02 +02:00
----- Set `Super + Return` to open Alacritty
2023-07-11 18:59:38 +02:00
---input.keybind({ "Super" }, input.keys.Return, function()
--- process.spawn("Alacritty")
---end)
---```
---@param key Keys The key for the keybind.
---@param modifiers (Modifier)[] Which modifiers need to be pressed for the keybind to trigger.
2023-07-11 18:59:38 +02:00
---@param action fun() What to do.
2023-07-22 04:02:02 +02:00
function input_module.keybind(modifiers, key, action)
2023-06-15 19:42:34 +02:00
table.insert(CallbackTable, action)
SendMsg({
SetKeybind = {
modifiers = modifiers,
key = key,
callback_id = #CallbackTable,
},
})
end
2023-07-22 04:02:02 +02:00
return input_module