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
A new bind works on the very next keypress — but it is lost when you change character or relog unless you save. Call core.keys.save() once after a batch of edits.
Mapping Types
Every key slot holds a type and an id. Use core.keys.type.* rather than the raw numbers.
| Type | Constant | Meaning | id is |
|---|---|---|---|
0 | EMPTY | Unbound | ignored |
1 | SKILL | Skill | skill ID |
2 | ITEM | Consumable item | item ID |
3 | FACE_ITEM | Face expression item | item ID |
4 | MENU | UI window / menu action | menu ID (see below) |
5 | ACTION | Basic action | action ID (see below) |
6 | EMOTE | Face expression | 100-106 |
7 | EFFECT_ITEM | Active effect item | item ID |
8 | MACRO | Skill macro | macro index, from 0 |
9 | CASH_ITEM | Cash inventory item | item ID |
Action IDs
Type 5 — the built-in binds (jump, pick up, and friends). These five are the only valid action IDs. Use core.keys.action.*.
| ID | Constant | Action | Default key |
|---|---|---|---|
50 | PICK_UP | Pick up item | Z |
51 | SIT | Sit down | X |
52 | ATTACK | Attack / regular attack | Ctrl |
53 | JUMP | Jump | Alt |
54 | NPC_CHAT | Talk to NPC / gather | Space |
core.keys.set_action(0x20, core.keys.action.JUMP) -- Space = jump
core.keys.set_action(0x5A, core.keys.action.PICK_UP) -- Z = pick up
core.keys.save()Emote IDs
Type 6 — the face expressions on the function-key row by default. Valid IDs are 100 through 106.
| ID | Default key |
|---|---|
100 | F1 |
101 | F2 |
102 | F3 |
103 | F5 |
104 | F6 |
105 | F7 |
106 | F8 |
Menu IDs
Type 4 — UI windows and menu toggles. Valid IDs are 0-49, 200-206, 300, and 1000-1001; anything else is rejected.
Other IDs inside the valid ranges are accepted but aren't listed here.
| ID | Opens | Default key |
|---|---|---|
0 | Equipment | E |
1 | Item Inventory | I |
2 | Stat | S |
3 | Skill | K |
5 | World Map | W |
6 | Messenger | C |
7 | Minimap (toggle) | M |
8 | Quest | Q |
14 | Menu | [ |
15 | Quickslot | ] |
16 | Chat (toggle) | ' |
17 | Guild | G |
20 | Quest Alarm (toggle) | L |
39 | Contents Guide | U |
48 | Capture Mode | — |
203 | Emoticon | — |
Presets
The game keeps three key presets, numbered 0-2. All the setters operate on whichever preset is currently applied.
Notes on key codes
A virtual-key code is translated to the game's own key-map slot, and that translation is not one-to-one:
- The right-hand modifiers share a slot with their left-hand twin, so binding
RShift/RCtrl/RAltchanges theLShift/LCtrl/LAltbind. - IME keys have no slot at all. Binding one raises an error rather than silently doing nothing.
Functions
core.keys.get(vkey: number) -> {type: number, id: number, index: number}
Available on GMS and CW
Returns the current game key mapping for a keyboard virtual-key code. index is the key-map slot for that key, which is useful when two keys share a slot.
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)
Available on GMS and CW
Sets a game key mapping to any supported type. The id is validated against the type, so an out-of-range action or menu ID raises an error instead of producing a dead key. Use unset() to clear a key.
core.keys.set(0x41, core.keys.type.SKILL, 1001004) -- A = skill
core.keys.set(0x42, core.keys.type.ITEM, 2000000) -- B = item
core.keys.set(0x20, core.keys.type.ACTION, core.keys.action.JUMP) -- Space = jumpcore.keys.set_skill(vkey: number, skill_id: number)
Available on GMS and CW
Sets a keyboard key to a skill.
core.keys.set_skill(0x41, 1001004) -- Acore.keys.set_item(vkey: number, item_id: number)
Available on GMS and CW
Sets a keyboard key to an item.
core.keys.set_item(0x42, 2000000) -- Bcore.keys.set_action(vkey: number, action_id: number)
Available on GMS and CW
Sets a keyboard key to a basic action such as jump or pick up. See Action IDs.
core.keys.set_action(0x20, core.keys.action.JUMP) -- Spacecore.keys.set_menu(vkey: number, menu_id: number)
Available on GMS and CW
Sets a keyboard key to a UI window or menu toggle. See Menu IDs.
core.keys.set_menu(0x49, 1) -- I = Item Inventorycore.keys.set_emote(vkey: number, emote_id: number)
Available on GMS and CW
Sets a keyboard key to a face expression. emote_id must be 100-106.
core.keys.set_emote(0x70, 100) -- F1core.keys.set_macro(vkey: number, macro_index: number)
Available on GMS and CW
Sets a keyboard key to a skill macro. macro_index starts at 0.
core.keys.set_macro(0x71, 0) -- F2 = first macrocore.keys.unset(vkey: number)
Available on GMS and CW
Clears a keyboard key mapping.
core.keys.save() -> boolean
Available on GMS and CW
Saves the active preset so the changes persist. Returns false when the server has key-map editing locked. Call this once after a batch of edits, not after every one.
core.keys.set_action(0x20, core.keys.action.JUMP)
core.keys.set_action(0x5A, core.keys.action.PICK_UP)
core.keys.save()core.keys.get_preset() -> number
Available on GMS and CW
Returns the active key preset, 0-2.
core.keys.set_preset(preset: number) -> boolean
Available on GMS and CW
Switches the active key preset. preset must be 0-2. Returns false when the server has key-map editing locked, in which case the game shows its own message.
core.keys.set_preset(1)core.keys.is_edit_blocked() -> boolean
Available on GMS and CW
Returns true while the server has key-map editing locked. save() and set_preset() both fail in that state.