Skip to content

Keys

Provides access to the game keyboard layout. These functions edit the game's key mapping table for the active key preset.

Key codes: Virtual Key Codes Reference

Mapping Types

TypeMeaning
0Empty
1Skill
2Item

Functions

core.keys.get(vkey: number) -> {type: number, id: number}

Returns the current game key mapping for a keyboard virtual-key code.

lua
local mapping = core.keys.get(0x41) -- A
core.log(string.format("type=%d id=%d", mapping.type, mapping.id))

core.keys.set(vkey: number, type: number, id: number)

Sets a game key mapping. type must be 1 for a skill or 2 for an item. Use unset() to clear a key.

lua
core.keys.set(0x41, 1, 1001004) -- A = skill
core.keys.set(0x42, 2, 2000000) -- B = item

core.keys.set_skill(vkey: number, skill_id: number)

Sets a keyboard key to a skill.

lua
core.keys.set_skill(0x41, 1001004) -- A

core.keys.set_item(vkey: number, item_id: number)

Sets a keyboard key to an item.

lua
core.keys.set_item(0x42, 2000000) -- B

core.keys.unset(vkey: number)

Clears a keyboard key mapping.