When you define a dialog with CreateDialog, you can specify which keyboard key will open or interact with it by using the key parameter. The value for key should come from the Keys lookup table shown below. For example, if you want the player to press E to start a dialog, you would set:
local Keys = {
["ESC"] = 322,
["F1"] = 288,
["F2"] = 289,
-- … (other mappings) …
["E"] = 38,
["ENTER"] = 18,
["SPACE"] = 22,
["LEFTCTRL"] = 36,
-- etc.
}
exports['koja-dialogs']:CreateDialog({
id = "example-dialog",
npc = "a_m_m_skater_01",
coords = vector4(100.0, 200.0, 300.0 - 1, 90.0),
name = "NPC Name",
message = "Hey, press the key to talk!",
tag = "Example",
animations = {
{ type = "idle", dict = "missfam5_yoga", anim = "idle_a" },
{ type = "active", dict = "missheist_agency2ah," anim = "talk_loop" }
},
key = 'E', -- <-- Use the value 38 here
actions = {
{
label = "Start Conversation",
player_message = "Hello!",
onclick = {
message = "How can I help you?",
actions = {},
},
close = true
}
}
})
How it works:
key = 'E'
This tells the dialog system to listen for control ID 38 (the “E” key).
When the player is near the NPC, pressing E will automatically open the dialog window—no need to write manual IsControlJustPressed(0, 38) checks.
You can replace Keys["E"] with any other entry from the Keys table (e.g. Keys["G"], Keys["SPACE"], Keys["ENTER"], etc.) to change which key triggers the dialog.
Refer to the full Keys table for all available mappings: